diff options
author | Chris Rees <crees@FreeBSD.org> | 2012-02-17 17:59:24 +0000 |
---|---|---|
committer | Chris Rees <crees@FreeBSD.org> | 2012-02-17 17:59:24 +0000 |
commit | 32624d403beeaf8db8d34ef0afc473b37c299917 (patch) | |
tree | 21184d08d895761032707e727302475007ed0acd /sysutils/su2/files/patch-su2-c | |
parent | - Update to 1.3.6 (diff) |
- Fix with utmpx for 9+ [1]
- Fix clang build
PR: ports/164660
Submitted by: Denis Generalov <gd@rambler-co.ru> [1]
Diffstat (limited to 'sysutils/su2/files/patch-su2-c')
-rw-r--r-- | sysutils/su2/files/patch-su2-c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/sysutils/su2/files/patch-su2-c b/sysutils/su2/files/patch-su2-c new file mode 100644 index 000000000000..8dae9239b519 --- /dev/null +++ b/sysutils/su2/files/patch-su2-c @@ -0,0 +1,74 @@ +--- su2.c.orig 2012-02-08 01:48:13.000000000 +0400 ++++ su2.c 2012-02-08 02:22:42.000000000 +0400 +@@ -151,7 +151,12 @@ + #include <fcntl.h> + #include <stdio.h> + #include <time.h> ++#include <osreldate.h> ++#if defined(__FreeBSD_version) && __FreeBSD_version >= 900007 ++#include <utmpx.h> ++#else + #include <utmp.h> ++#endif + #include <signal.h> + #ifdef IOCTL + #include <sys/ioctl.h> +@@ -383,7 +388,12 @@ + if (FullTTY == (char *) 0) + FullTTY = "/dev/TTY??"; + +- TTY = strrchr (FullTTY, '/') + 1; ++ TTY = FullTTY + strlen(FullTTY); ++ while (TTY > FullTTY) { ++ if (TTY[-1] == '/' && (TTY[0] > 57 || TTY[0] < 48)) ++ break; ++ TTY--; ++ } + + Debug (1, "-> FullTTY=\"%s\"\n", FullTTY); + Debug (1, "-> TTY=\"%s\"\n", TTY); +@@ -1315,7 +1325,11 @@ + * Copies name into an internal static buffer. + */ + ++#if __FreeBSD_version >= 900007 ++#define MAXNAME sizeof(((struct utmpx *)nptr)->ut_user) ++#else + #define MAXNAME sizeof(((struct utmp *)nptr)->ut_name) ++#endif + + #ifdef BROKENCUSERID + char *mycuserid () +@@ -1432,6 +1446,24 @@ + ModifyUtmp (NewUserName) + register char *NewUserName; + { ++#if __FreeBSD_version >= 900007 ++ struct utmpx ut, *utr; ++ ++ strncpy(ut.ut_line, TTY, sizeof(ut.ut_line)); ++ setutxent(); ++ if ((utr = getutxline(&ut)) == NULL) { ++ endutxent(); ++ (void) fprintf (stderr, "Terminal %s not found\n", ut.ut_line); ++ return (1); ++ } ++ strncpy(utr->ut_user, NewUserName, sizeof(utr->ut_user)); ++ if (pututxline(utr) == NULL) { ++ endutxent(); ++ (void) fprintf (stderr, "pututxline failed\n"); ++ return (1); ++ } ++ endutxent(); ++#else + register int fd; /* /etc/utmp file */ + register int i; /* index */ + #ifdef hpux +@@ -1482,6 +1514,7 @@ + + (void) write (fd, (char *) & Utmp, sizeof (Utmp)); + (void) close (fd); ++#endif + return (0); + } + |