74 lines
1.8 KiB
Text
74 lines
1.8 KiB
Text
--- 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);
|
|
}
|
|
|