News from AIX
Gert Doering
gert at greenie.muc.de
Fri Mar 16 02:22:30 EST 2001
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".
gert
-------
Index: session.c
===================================================================
RCS file: /cvs/openssh_cvs/session.c,v
retrieving revision 1.79
diff -u -r1.79 session.c
--- session.c 2001/02/18 19:13:34 1.79
+++ session.c 2001/03/15 15:13:44
@@ -89,6 +89,10 @@
# define S_UNOFILE_HARD S_UNOFILE "_hard"
#endif
+#ifdef _AIX
+# include <uinfo.h>
+#endif
+
/* types */
#define TTYSZ 64
@@ -1119,6 +1123,25 @@
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
+ */
+ {
+ char ui_buf[1000];
+ int ui_len;
+
+ ui_len = sprintf( ui_buf,
+ "LOGNAME=%s%cNAME=%s%cTTY=%s%c%c",
+ pw->pw_name, 0,
+ pw->pw_name, 0,
+ ttyname, 0,0);
+ usrinfo( SETUINFO, ui_buf, ui_len );
+ debug("AIX/UsrInfo: set len %d", ui_len);
+ }
+#endif
/* Permanently switch to the desired uid. */
permanently_set_uid(pw->pw_uid);
--------- snip ---------
usrinfo Subroutine
Purpose
Gets and sets user information about the owner of the current process.
Library
Standard C Library (libc.a)
Syntax
#include <uinfo.h>
int usrinfo (Command, Buffer, Count)
int Command;
char *Buffer;
int Count;
Description
The usrinfo subroutine gets and sets information about the owner of
the current process. The information is a sequence of null-terminated
name=value strings. The last string in the sequence is terminated
by two successive null characters. A child process inherits the user
information of the parent process.
Parameters
Command Specifies one of the following constants:
GETUINFO Copies user information, up to the number of bytes specified
by the Count parameter, into the buffer pointed to by the Buffer parameter.
SETUINFO Sets the user information for the process to the number of
bytes specified by the Count parameter in the buffer pointed to by
the Buffer parameter. The calling process must have root user authority
to set the user information.
The minimum user information consists of four strings typically set
by the login program:
NAME=UserName
LOGIN=LoginName
LOGNAME=LoginName
TTY=TTYName
If the process has no terminal, the TTYName parameter should be null.
Buffer Specifies a pointer to a user buffer. This buffer is usually
UINFOSIZ bytes long.
Count Specifies the number of bytes of user information copied from
or to the user buffer.
Return Values
If successful, the usrinfo subroutine returns a non-negative integer
giving the number of bytes transferred. Otherwise, a value of -1 is
returned and the errno global variable is set to indicate the error.
Error Codes
The usrinfo subroutine fails if one of the following is true:
EPERM The Command parameter is set to SETUINFO, and the calling process
does not have root user authority.
EINVAL The Command parameter is not set to SETUINFO or GETUINFO.
EINVAL The Command parameter is set to SETUINFO, and the Count parameter
is larger than UINFOSIZ.
EFAULT The Buffer parameter points outside of the address space of
the process.
Implementation Specifics
This subroutine is part of Base Operating System (BOS) Runtime.
Related Information
The getuinfo subroutine, setpenv subroutine.
The login command.
List of Security and Auditing Subroutines in AIX Version 4 General
Programming Concepts: Writing and Debugging Programs.
Subroutines Overview in AIX Version 4 General Programming Concepts:
Writing and Debugging Programs.
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany gert at greenie.muc.de
fax: +49-89-35655025 gert.doering at physik.tu-muenchen.de
More information about the openssh-unix-dev
mailing list