summaryrefslogtreecommitdiff
path: root/openbsd-compat/port-aix.c
blob: ca0a88e692ac3a797ca3a5e2f315ed012db562cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "includes.h"

#ifdef _AIX

#include <uinfo.h>
#include <../xmalloc.h>

/*
 * 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
 */
void
aix_usrinfo(struct passwd *pw, char *tty, int ttyfd) 
{
	u_int i;
	char *cp=NULL;

	if (ttyfd == -1)
		tty[0] = '\0';
	cp = xmalloc(22 + strlen(tty) + 2 * strlen(pw->pw_name));
	i = sprintf(cp, "LOGNAME=%s%cNAME=%s%cTTY=%s%c%c", pw->pw_name, 0, 
	    pw->pw_name, 0, tty, 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 /* _AIX */