[dev] [utmp][PATCH 1/3] Change name of pass structure

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Tue, 16 Sep 2014 08:47:59 +0200

It is idiomatic the use of the simple pw instead of pass for
variables of type struct pass.
---
 bsd.c   |  8 ++++----
 posix.c |  8 ++++----
 utmp.c  | 14 +++++++-------
 3 files changed, 15 insertions(+), 15 deletions(-)
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);
-- 
1.9.3
Received on Tue Sep 16 2014 - 08:47:59 CEST

This archive was generated by hypermail 2.3.0 : Tue Sep 16 2014 - 09:00:12 CEST