Add ability to only beep when mail arrives.
comsat: only send two bell charecters if S_IXGRP is set and S_IXUSR is not. biff: add new option 'b' to set S_IXGRP. PR: 10931 Submitted by: Andrew J. Korty <ajk@purdue.edu> Approved by: sheldonh (mentor) MFC after: 1 month
This commit is contained in:
parent
894429f29b
commit
7da9dccb66
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99632
@ -76,6 +76,13 @@ or
|
|||||||
.Dq Subject
|
.Dq Subject
|
||||||
lines are not included in the displayed message.
|
lines are not included in the displayed message.
|
||||||
.Pp
|
.Pp
|
||||||
|
If the
|
||||||
|
.Em user
|
||||||
|
specified is logged in to the system and the associated terminal has
|
||||||
|
the group execute bit turned on (by a
|
||||||
|
.Dq Li biff b ) ,
|
||||||
|
two bell characters (ASCII \\007) are printed on the user's terminal.
|
||||||
|
.Pp
|
||||||
If mailbox-name omitted, standard mailbox assumed.
|
If mailbox-name omitted, standard mailbox assumed.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width /var/mail/user -compact
|
.Bl -tag -width /var/mail/user -compact
|
||||||
|
@ -211,7 +211,7 @@ notify(struct utmp *utp, char file[], off_t offset, int folder)
|
|||||||
syslog(LOG_AUTH | LOG_NOTICE, "'/' in \"%s\"", tty);
|
syslog(LOG_AUTH | LOG_NOTICE, "'/' in \"%s\"", tty);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stat(tty, &stb) || !(stb.st_mode & S_IEXEC)) {
|
if (stat(tty, &stb) || !(stb.st_mode & (S_IXUSR | S_IXGRP))) {
|
||||||
dsyslog(LOG_DEBUG, "%s: wrong mode on %s", utp->ut_name, tty);
|
dsyslog(LOG_DEBUG, "%s: wrong mode on %s", utp->ut_name, tty);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -228,11 +228,25 @@ notify(struct utmp *utp, char file[], off_t offset, int folder)
|
|||||||
cr = ((tio.c_oflag & (OPOST|ONLCR)) == (OPOST|ONLCR)) ? "\n" : "\n\r";
|
cr = ((tio.c_oflag & (OPOST|ONLCR)) == (OPOST|ONLCR)) ? "\n" : "\n\r";
|
||||||
(void)strncpy(name, utp->ut_name, sizeof(utp->ut_name));
|
(void)strncpy(name, utp->ut_name, sizeof(utp->ut_name));
|
||||||
name[sizeof(name) - 1] = '\0';
|
name[sizeof(name) - 1] = '\0';
|
||||||
(void)fprintf(tp, "%s\007New mail for %s@%.*s\007 has arrived%s%s%s:%s----%s",
|
switch (stb.st_mode & (S_IXUSR | S_IXGRP)) {
|
||||||
cr, name, (int)sizeof(hostname), hostname,
|
case S_IXUSR:
|
||||||
folder ? cr : "", folder ? "to " : "", folder ? file : "",
|
case (S_IXUSR | S_IXGRP):
|
||||||
cr, cr);
|
(void)fprintf(tp,
|
||||||
jkfprintf(tp, name, file, offset);
|
"%s\007New mail for %s@%.*s\007 has arrived%s%s%s:%s----%s",
|
||||||
|
cr, name, (int)sizeof(hostname), hostname,
|
||||||
|
folder ? cr : "", folder ? "to " : "", folder ? file : "",
|
||||||
|
cr, cr);
|
||||||
|
jkfprintf(tp, name, file, offset);
|
||||||
|
break;
|
||||||
|
case S_IXGRP:
|
||||||
|
(void)fprintf(tp, "\007");
|
||||||
|
(void)fflush(tp);
|
||||||
|
(void)sleep(1);
|
||||||
|
(void)fprintf(tp, "\007");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
(void)fclose(tp);
|
(void)fclose(tp);
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
.Nd "be notified if mail arrives and who it is from"
|
.Nd "be notified if mail arrives and who it is from"
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Cm n | y
|
.Op Cm n | y | b
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
@ -52,11 +52,13 @@ The following options are available:
|
|||||||
.It Cm n
|
.It Cm n
|
||||||
Disable notification.
|
Disable notification.
|
||||||
.It Cm y
|
.It Cm y
|
||||||
Enable notification.
|
Enable header notification.
|
||||||
|
.It Cm b
|
||||||
|
Enable bell notification.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
When mail notification is enabled, the header and first few lines of
|
When header notification is enabled, the header and first few lines of
|
||||||
the message will be printed on your screen whenever mail arrives.
|
the message will be printed on your terminal whenever mail arrives.
|
||||||
A
|
A
|
||||||
.Dq Li biff y
|
.Dq Li biff y
|
||||||
command is often included in the file
|
command is often included in the file
|
||||||
@ -65,6 +67,9 @@ or
|
|||||||
.Pa \&.profile
|
.Pa \&.profile
|
||||||
to be executed at each login.
|
to be executed at each login.
|
||||||
.Pp
|
.Pp
|
||||||
|
When bell notification is enabled, only two bell characters (ASCII \\007)
|
||||||
|
will be printed on your terminal whenever mail arrives.
|
||||||
|
.Pp
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
utility operates asynchronously.
|
utility operates asynchronously.
|
||||||
|
@ -81,28 +81,35 @@ main(argc, argv)
|
|||||||
err(2, "stat");
|
err(2, "stat");
|
||||||
|
|
||||||
if (*argv == NULL) {
|
if (*argv == NULL) {
|
||||||
(void)printf("is %s\n", sb.st_mode & S_IXUSR ? "y" : "n");
|
(void)printf("is %s%s\n",
|
||||||
return(sb.st_mode & S_IXUSR ? 0 : 1);
|
sb.st_mode & S_IXUSR ? "y" :
|
||||||
|
sb.st_mode & S_IXGRP ? "b" : "n");
|
||||||
|
return(sb.st_mode & (S_IXUSR | S_IXGRP) ? 0 : 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(argv[0][0]) {
|
switch(argv[0][0]) {
|
||||||
case 'n':
|
case 'n':
|
||||||
if (chmod(name, sb.st_mode & ~S_IXUSR) < 0)
|
if (chmod(name, sb.st_mode & ~(S_IXUSR | S_IXGRP)) < 0)
|
||||||
err(2, "%s", name);
|
err(2, "%s", name);
|
||||||
break;
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
if (chmod(name, sb.st_mode | S_IXUSR) < 0)
|
if (chmod(name, (sb.st_mode & ~(S_IXUSR | S_IXGRP)) | S_IXUSR) < 0)
|
||||||
|
err(2, "%s", name);
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
if (chmod(name, (sb.st_mode & ~(S_IXUSR | S_IXGRP)) | S_IXGRP) < 0)
|
||||||
err(2, "%s", name);
|
err(2, "%s", name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
return(sb.st_mode & S_IXUSR ? 0 : 1);
|
return(sb.st_mode & (S_IXUSR | S_IXGRP) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage: biff [y | n]\n");
|
(void)fprintf(stderr, "usage: biff [n | y | b]\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user