setlogin() : do we have it in QNX4? (+)

Looking into the unix3*.lib one can find setlogin.o there.
The documentation for Watcom C v10.6 does not list it as available one.

If it’s usable, what is it’s prototype?

The prototype is: int setlogin( char*logname);

But, good news (not!), it’s crippled in the last release of the library.
In a previous news group discussion a solution was supplied by someone
at QSSL.

int setlogin( char *name )
{
struct _proc_session ps;
u_short s = 0;

memset( &ps, 0, sizeof( ps ) );
ps.type = _PROC_SESSION;
ps.subtype = _PROC_SUB_ACTION1;
ps.sid = getsid( getpid( ) );
strncpy( ps.name, name, 16 );

Send( PROC_PID, &ps, &s, sizeof( ps ), sizeof( s ) );

errno = s;

if ( s != 0 )
return( -1 );

return( s );
}
Hope that helps :wink:

-Rob

Tony wrote:

Looking into the unix3*.lib one can find setlogin.o there.
The documentation for Watcom C v10.6 does not list it as available one.

If it’s usable, what is it’s prototype?

On Mon, 12 Apr 2004 10:18:08 -0500, Rob Hem <rob@spamyourself.com> wrote:

The prototype is: int setlogin( char*logname);

But, good news (not!), it’s crippled in the last release of the library.
In a previous news group discussion a solution was supplied by someone
at QSSL.

int setlogin( char *name )
{
struct _proc_session ps;
u_short s = 0;

memset( &ps, 0, sizeof( ps ) );
ps.type = _PROC_SESSION;
ps.subtype = _PROC_SUB_ACTION1;
ps.sid = getsid( getpid( ) );
strncpy( ps.name, name, 16 );

Send( PROC_PID, &ps, &s, sizeof( ps ), sizeof( s ) );

errno = s;

if ( s != 0 )
return( -1 );

return( s );
}
Hope that helps > :wink:

This is what I’ve found in the port of ssh-1.2.26 (sshd.c):

#ifdef QNX
#include <sys/types.h>
#include <sys/proc_msg.h>
#include <sys/kernel.h>
#include <string.h>
#include <errno.h>

struct _proc_session ps;
struct _proc_session_reply rps;

int qsetlogin(char *login, char *ttyname)
{
int v = getsid(getpid());

memset(&ps, 0, sizeof(ps));
memset(&rps, 0, sizeof(rps));

ps.type = _PROC_SESSION;
ps.subtype = _PROC_SUB_ACTION1;
ps.sid = v;
strcpy(ps.name, login);
Send(1, &ps, &rps, sizeof(ps), sizeof(rps));

ps.type = _PROC_SESSION;
ps.subtype = _PROC_SUB_ACTION2;
ps.sid = v;
sprintf(ps.name, “//%d%s”, getnid(), ttyname);
Send(1, &ps, &rps, sizeof(ps), sizeof(rps));

return (rps.status);
}

Are the both versions equivalent?

Tony wrote:

On Mon, 12 Apr 2004 10:18:08 -0500, Rob Hem <> rob@spamyourself.com> > wrote:

The prototype is: int setlogin( char*logname);

But, good news (not!), it’s crippled in the last release of the
library. In a previous news group discussion a solution was supplied
by someone at QSSL.

int setlogin( char *name )
{
struct _proc_session ps;
u_short s = 0;

memset( &ps, 0, sizeof( ps ) );
ps.type = _PROC_SESSION;
ps.subtype = _PROC_SUB_ACTION1;
ps.sid = getsid( getpid( ) );
strncpy( ps.name, name, 16 );

Send( PROC_PID, &ps, &s, sizeof( ps ), sizeof( s ) );

errno = s;

if ( s != 0 )
return( -1 );

return( s );
}
Hope that helps > :wink:


This is what I’ve found in the port of ssh-1.2.26 (sshd.c):

#ifdef QNX
#include <sys/types.h
#include <sys/proc_msg.h
#include <sys/kernel.h
#include <string.h
#include <errno.h

struct _proc_session ps;
struct _proc_session_reply rps;

int qsetlogin(char *login, char *ttyname)
{
int v = getsid(getpid());

memset(&ps, 0, sizeof(ps));
memset(&rps, 0, sizeof(rps));

ps.type = _PROC_SESSION;
ps.subtype = _PROC_SUB_ACTION1;
ps.sid = v;
strcpy(ps.name, login);
Send(1, &ps, &rps, sizeof(ps), sizeof(rps));

ps.type = _PROC_SESSION;
ps.subtype = _PROC_SUB_ACTION2;
ps.sid = v;
sprintf(ps.name, “//%d%s”, getnid(), ttyname);
Send(1, &ps, &rps, sizeof(ps), sizeof(rps));

return (rps.status);
}

Are the both versions equivalent?

My best guess (not being an employee of QSSL) is, yes. The first part
of it looks to be the basically the same as the setlogin() function.
The second part is obviously setting the name of the controlling terminal.

This is part of the stuff that shows up in the struct _psinfo when
qnx_psinfo() is called and what is displayed by ‘who’. It doesn’t set
the LOGNAME environment var. And, I’m not really sure how it affects or
is associated with tcsetct() or the actual functioning of a running process.

-Rob

On Mon, 12 Apr 2004 11:30:04 -0500, Rob Hem <rob@spamyourself.com> wrote:

Are the both versions equivalent?

My best guess (not being an employee of QSSL) is, yes. The first part
of it looks to be the basically the same as the setlogin() function. The
second part is obviously setting the name of the controlling terminal.

This is part of the stuff that shows up in the struct _psinfo when
qnx_psinfo() is called and what is displayed by ‘who’. It doesn’t set
the LOGNAME environment var. And, I’m not really sure how it affects or
is associated with tcsetct() or the actual functioning of a running
process.

Is it worth trying to compile the code that you’ve first shown me as
setlogin.c to obtain setlogin.o and then to replace the faulty module in
the unix3*.lib?

(
Provided that I do it two times:
cc -mf -4r -o setlogin3r.o
cc -mf -4s -o setlogin3s.o
)

Please comment.

Tony

Only YOU can decide whether it’s worth it or not :wink:

Personally, since it’s so seldom used or needed, I just include it as a
static function in any custom source I may need to work on.

If you must have it in a library, putting it in your own library, might
be more maintainable over time… if/when there is another lib update
from QSSL, you’d have to remember to do the unix3{rs}.lib patches again.

-Rob

Tony wrote:

On Mon, 12 Apr 2004 11:30:04 -0500, Rob Hem <> rob@spamyourself.com> > wrote:

Are the both versions equivalent?


My best guess (not being an employee of QSSL) is, yes. The first part
of it looks to be the basically the same as the setlogin() function.
The second part is obviously setting the name of the controlling
terminal.

This is part of the stuff that shows up in the struct _psinfo when
qnx_psinfo() is called and what is displayed by ‘who’. It doesn’t set
the LOGNAME environment var. And, I’m not really sure how it affects
or is associated with tcsetct() or the actual functioning of a running
process.


Is it worth trying to compile the code that you’ve first shown me as
setlogin.c to obtain setlogin.o and then to replace the faulty module in
the unix3*.lib?

(
Provided that I do it two times:
cc -mf -4r -o setlogin3r.o
cc -mf -4s -o setlogin3s.o
)

Please comment.

Tony

On Mon, 12 Apr 2004 14:13:32 -0500, Rob Hem <rob@spamyourself.com> wrote:

… if/when there is another lib update from QSSL…

I still hope! :slight_smile: