utmp

simple login manager
git clone git://git.suckless.org/utmp
Log | Files | Refs | README | LICENSE

commit 8fcc4a561cbdbfb4bf67a2b3f7574d35b7c10e49
parent 81d0a50c7392fc4c985b0e71e708ccdd3815441a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 22 Feb 2015 16:30:21 +0000

Add utmp string in error messages

Utmp may be executed from st, and sometimes is difficult to see
who generate the error, so this patch helps.

Diffstat:
Mbsd.c | 6+++---
Mposix.c | 10+++++-----
Mutmp.c | 6+++---
3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/bsd.c b/bsd.c @@ -26,17 +26,17 @@ addutmp(void) host = "-"; if (strlen(pw->pw_name) > sizeof(utmp.ut_name)) - die("incorrect username %s", pw->pw_name); + die("utmp:incorrect username %s", pw->pw_name); if ((pts = ttyname(STDIN_FILENO)) == NULL) - die("error getting pty name:%s", strerror(errno)); + die("utmp:error getting pty name:%s", strerror(errno)); for (cp = pts + strlen(pts) - 1; isdigit(*cp); --cp) /* nothing */; ptyid = atoi(++cp); if (ptyid > 999 || strlen(pts + 5) > sizeof(utmp.ut_line)) - die("Incorrect pts name %s\n", pts); + die("utmp:Incorrect pts name %s\n", pts); /* remove /dev/ from pts */ strncpy(utmp.ut_line, pts + 5, sizeof(utmp.ut_line)); diff --git a/posix.c b/posix.c @@ -70,17 +70,17 @@ addutmp(void) char *pts, *cp, buf[5] = {'x'}; if (strlen(pw->pw_name) > sizeof(utmp.ut_user)) - die("incorrect username %s", pw->pw_name); + die("utmp:incorrect username %s", pw->pw_name); if ((pts = ttyname(STDIN_FILENO)) == NULL) - die("error getting pty name\n"); + die("utmp:error getting pty name\n"); for (cp = pts + strlen(pts) - 1; isdigit(*cp); --cp) /* nothing */; ptyid = atoi(++cp); if (ptyid > 999 || strlen(pts + 5) > sizeof(utmp.ut_line)) - die("Incorrect pts name %s\n", pts); + die("utmp:Incorrect pts name %s\n", pts); sprintf(buf + 1, "%03d", ptyid); strncpy(utmp.ut_id, buf, 4); @@ -99,7 +99,7 @@ addutmp(void) setegid(egid); if(!pututxline(&utmp)) - die("error adding utmp entry:%s", strerror(errno)); + die("utmp:error adding utmp entry:%s", strerror(errno)); setegid(gid); endutxent(); } @@ -115,7 +115,7 @@ delutmp(void) r->ut_tv.tv_usec = r->ut_tv.tv_sec = 0; setgid(egid); if (!pututxline(r)) - die("error removing utmp entry:%s", strerror(errno)); + die("utmp:error removing utmp entry:%s", strerror(errno)); setgid(gid); } endutxent(); diff --git a/utmp.c b/utmp.c @@ -46,9 +46,9 @@ main(int argc, char *argv[]) errno = 0; if ((pw = getpwuid(uid = getuid())) == NULL) { if(errno) - die("getpwuid:%s", strerror(errno)); + die("utmp:getpwuid:%s", strerror(errno)); else - die("who are you?"); + die("utmp:who are you?"); } setenv("LOGNAME", pw->pw_name, 1); @@ -83,7 +83,7 @@ main(int argc, char *argv[]) sigprocmask(SIG_UNBLOCK, &set, NULL); if (wait(&status) == -1) - perror("error waiting child"); + perror("utmp:error waiting child"); delutmp(); } return (WIFEXITED(status)) ? WEXITSTATUS(status) : EXIT_FAILURE;