setlogin

I posted this to comp.os.qnx yesterday but this may be a better forum…

I had to write my own login to duplicate functionality in a QNX2 system I am
porting. In my login, which is spawned in its own session (_SPAWN_SETSID)
from a terminal monitor program (my own again), I do:


chdir (user dir)

setlogin(username)
setuid(0);
setgid(0);
execve (cmd, params, env);

Almost everything works as expected. The problem I am having is that the
user name specified by setlogin() is not visible with “who” and query_sid()
etc. What have I missed? Is there another call (undocumented?) that I have
to make to convince the system that my user has a different login name?

None of my users are in the passwd database. My application has its own
greatly expanded database for system privileges etc. which is not easily
adapted to /etc/passwd

Thanks for all help

Regards
DTHV

David Verbrugge <dverbrugge-nospam-@home.com> wrote:
: I posted this to comp.os.qnx yesterday but this may be a better forum…

: I had to write my own login to duplicate functionality in a QNX2 system I am
: porting. In my login, which is spawned in its own session (_SPAWN_SETSID)
: from a terminal monitor program (my own again), I do:

: …
: chdir (user dir)
: …
: setlogin(username)
: setuid(0);
: setgid(0);
: execve (cmd, params, env);

: Almost everything works as expected. The problem I am having is that the
: user name specified by setlogin() is not visible with “who” and query_sid()
: etc. What have I missed? Is there another call (undocumented?) that I have
: to make to convince the system that my user has a different login name?

For the ‘who’ utility you need to write out entries to the
utmp file with the pututline() function.

In a nutshell the qnx login ends up with:

write utmp log
chmod(tty)
chown(tty)
sid_name(getsid(0), pw_name);
environment saving/mangling
chdir(dir)
setgid(gid), setegid(gid)
setuid(uid), seteuid(uid)
exec()

: None of my users are in the passwd database. My application has its own
: greatly expanded database for system privileges etc. which is not easily
: adapted to /etc/passwd

Thomas

Thomas (toe-mah) Fletcher QNX Software Systems
thomasf@qnx.com Neutrino Development Group
(613)-591-0931 http://www.qnx.com/~thomasf

“Thomas Fletcher” <thomasf@qnx.com> wrote in message
news:8ogrt5$9k7$1@nntp.qnx.com

David Verbrugge <> dverbrugge-nospam-@home.com> > wrote:
: I posted this to comp.os.qnx yesterday but this may be a better forum…

: I had to write my own login to duplicate functionality in a QNX2 system
I am
: porting. In my login, which is spawned in its own session
(_SPAWN_SETSID)
: from a terminal monitor program (my own again), I do:

: …
: chdir (user dir)
: …
: setlogin(username)
: setuid(0);
: setgid(0);
: execve (cmd, params, env);

: Almost everything works as expected. The problem I am having is that the
: user name specified by setlogin() is not visible with “who” and
query_sid()
: etc. What have I missed? Is there another call (undocumented?) that I
have
: to make to convince the system that my user has a different login name?

For the ‘who’ utility you need to write out entries to the
utmp file with the pututline() function.

In a nutshell the qnx login ends up with:

write utmp log
chmod(tty)
chown(tty)
sid_name(getsid(0), pw_name);
environment saving/mangling
chdir(dir)
setgid(gid), setegid(gid)
setuid(uid), seteuid(uid)
exec()

: None of my users are in the passwd database. My application has its own
: greatly expanded database for system privileges etc. which is not easily
: adapted to /etc/passwd

Thomas

Thomas (toe-mah) Fletcher QNX Software Systems
thomasf@qnx.com > Neutrino Development Group
(613)-591-0931 > http://www.qnx.com/~thomasf

I found pututline() in <utmp.h> but I did not find a prototype for
sid_name().
I tried using only pututline() without sid_name() and did not have success.

Where can I find sid_name() ? Is it a QNX4 function ?

Thanks
DTHV