News from AIX

Damien Miller djm at mindrot.org
Fri Mar 16 10:16:44 EST 2001


On Thu, 15 Mar 2001, Gert Doering wrote:

> Hi,
>
> News from the "AIX is different than the rest of the world" department...
>
> AIX has something similar to setluid() on SCO, just that it uses text
> strings (similar to setenv()) and calls it "usrinfo".  I've appended
> the man page below.
>
> Under normal conditions, well-behaved applications use ttyname(),
> logname() and getuid() get the relevant informations, but today I've
> come across one piece of commercial software that insists on using
> usrinfo(), and otherwise failed to use the proper user name when
> being called in an ssh session.  So I'm afraid we have to support that.
>
> To my knowledge, usrinfo() is valid on all AIX systems ever shipped.
>
> Patch is also appended - with that, reading usrinfo() in an ssh session
> shows the same value as in a telnet session, so that should be "fine".

Thanks - how does this work for you? It is based on you patch, except
the buffer is exactly allocated and usrinfo's return value is checked.

-d

Index: session.c
===================================================================
RCS file: /var/cvs/openssh/session.c,v
retrieving revision 1.89
diff -u -r1.89 session.c
--- session.c	2001/03/05 07:33:15	1.89
+++ session.c	2001/03/15 23:15:44
@@ -89,6 +89,10 @@
 # define S_UNOFILE_HARD	S_UNOFILE "_hard"
 #endif

+#ifdef _AIX
+# include <uinfo.h>
+#endif
+
 /* types */

 #define TTYSZ 64
@@ -1135,6 +1139,23 @@
 					debug("error setting satid: %.100s", strerror(errno));
 			}
 #endif /* WITH_IRIX_AUDIT */
+
+#ifdef _AIX
+			/*
+			 * AIX has a "usrinfo" area where logname and
+			 * other stuff is stored - a few applications
+			 * actually use this and die if it's not set
+			 */
+			cp = xmalloc(22 + strlen(ttyname) +
+			    2 * strlen(pw->pw_name));
+			i = sprintf(cp, "LOGNAME=%s%cNAME=%s%cTTY=%s%c%c",
+			    pw->pw_name, 0, pw->pw_name, 0, ttyname, 0,0);
+			if (usrinfo(SETUINFO, cp, i) == -1)
+				fatal("Couldn't set usrinfo: %s",
+				    strerror(errno));
+			debug3("AIX/UsrInfo: set len %d", i);
+			xfree(cp);
+#endif

 			/* Permanently switch to the desired uid. */
 			permanently_set_uid(pw->pw_uid);


-- 
| Damien Miller <djm at mindrot.org> \ ``E-mail attachments are the poor man's
| http://www.mindrot.org          /   distributed filesystem'' - Dan Geer






More information about the openssh-unix-dev mailing list