[hackers] [utmp] Change name of pass structure || Roberto E. Vargas Caballero
commit 5ac5ede22b55ec5820dbacf1c5e5e9d9c2b2d9ad
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Thu Aug 28 11:37:41 2014 +0200
Change name of pass structure
It is idiomatic the use of the simple pw instead of pass for
variables of type struct pass.
diff --git a/bsd.c b/bsd.c
index cb455a2..754d1d0 100644
--- a/bsd.c
+++ b/bsd.c
_AT_@ -11,7 +11,7 @@
#include <pwd.h>
extern void die(const char *fmt, ...);
-extern struct passwd *pass;
+extern struct passwd *pw;
extern gid_t egid, gid;
static struct utmp utmp;
_AT_@ -25,8 +25,8 @@ addutmp(void)
if (!(host = getenv("DISPLAY")))
host = "-";
- if (strlen(pass->pw_name) > sizeof(utmp.ut_name))
- die("incorrect username %s", pass->pw_name);
+ if (strlen(pw->pw_name) > sizeof(utmp.ut_name))
+ die("incorrect username %s", pw->pw_name);
if ((pts = ttyname(STDIN_FILENO)) == NULL)
die("error getting pty name:%s", strerror(errno));
_AT_@ -40,7 +40,7 @@ addutmp(void)
/* remove /dev/ from pts */
strncpy(utmp.ut_line, pts + 5, sizeof(utmp.ut_line));
- strncpy(utmp.ut_name, pass->pw_name, sizeof(utmp.ut_name));
+ strncpy(utmp.ut_name, pw->pw_name, sizeof(utmp.ut_name));
strncpy(utmp.ut_host, host, sizeof(utmp.ut_host));
time(&utmp.ut_time);
diff --git a/posix.c b/posix.c
index df70929..8f904c4 100644
--- a/posix.c
+++ b/posix.c
_AT_@ -29,7 +29,7 @@
extern void die(const char *fmt, ...);
static struct utmpx utmp;
-extern struct passwd *pass;
+extern struct passwd *pw;
extern gid_t egid, gid;
_AT_@ -70,8 +70,8 @@ addutmp(void)
unsigned ptyid;
char *pts, *cp, buf[5] = {'x'};
- if (strlen(pass->pw_name) > sizeof(utmp.ut_user))
- die("incorrect username %s", pass->pw_name);
+ if (strlen(pw->pw_name) > sizeof(utmp.ut_user))
+ die("incorrect username %s", pw->pw_name);
if ((pts = ttyname(STDIN_FILENO)) == NULL)
die("error getting pty name\n");
_AT_@ -92,7 +92,7 @@ addutmp(void)
findutmp(USER_PROCESS);
utmp.ut_type = USER_PROCESS;
- strncpy(utmp.ut_user, pass->pw_name, sizeof(utmp.ut_user));
+ strncpy(utmp.ut_user, pw->pw_name, sizeof(utmp.ut_user));
utmp.ut_pid = getpid();
utmp.ut_tv.tv_sec = time(NULL);
utmp.ut_tv.tv_usec = 0;
diff --git a/utmp.c b/utmp.c
index 4b79b78..bda11d3 100644
--- a/utmp.c
+++ b/utmp.c
_AT_@ -19,7 +19,7 @@
#endif
-struct passwd *pass;
+struct passwd *pw;
gid_t egid, gid;
_AT_@ -46,14 +46,14 @@ main(int argc, char *argv[])
gid = getgid();
setgid(gid);
- pass = getpwuid(uid = getuid());
- if (!pass || !pass->pw_name)
+ pw = getpwuid(uid = getuid());
+ if (!pw || !pw->pw_name)
die("Process is running with an incorrect uid %d", uid);
- setenv("LOGNAME", pass->pw_name, 1);
- setenv("USER", pass->pw_name, 1);
- setenv("SHELL", pass->pw_shell, 0);
- setenv("HOME", pass->pw_dir, 0);
+ setenv("LOGNAME", pw->pw_name, 1);
+ setenv("USER", pw->pw_name, 1);
+ setenv("SHELL", pw->pw_shell, 1);
+ setenv("HOME", pw->pw_dir, 1);
sigfillset(&set);
sigprocmask(SIG_BLOCK, &set, NULL);
Received on Wed Sep 17 2014 - 10:01:39 CEST
This archive was generated by hypermail 2.3.0
: Wed Sep 17 2014 - 10:12:08 CEST