Phone program source

Hur, Jinho jhhur at kaist.UUCP
Tue Jan 15 02:54:53 AEST 1985


The phone program has some anomaly.
When user A su'ed on the login by B, phone to C, then the message to C
says that A rings C. But when C tries to ring A by 'phone A', 
'User not logged in' message appears. It is since phone uses 
getpwuid(getuid()) for the local user name. It is to be corrected as follows
to avoid such anomaly.

*** phone.c	Sun Jan 13 22:51:31 1985
--- phone.c.old	Sun Jan 13 22:50:09 1985
***************
*** 26,32
     int  dpid;				/* daemon pid */
     char psockname[80];			/* phone socket name */
     struct passwd *pw;			/* pointer to password structure */
-    struct passwd *getpwnam();
     int nodaemon(),daemonstarted();	/* predeclare for signal	*/
     char *getlogin();			/* to avoid confusion. */
  

--- 26,31 -----
     int  dpid;				/* daemon pid */
     char psockname[80];			/* phone socket name */
     struct passwd *pw;			/* pointer to password structure */
     int nodaemon(),daemonstarted();	/* predeclare for signal	*/
  
     /* Check the number of arguments */
***************
*** 28,34
     struct passwd *pw;			/* pointer to password structure */
     struct passwd *getpwnam();
     int nodaemon(),daemonstarted();	/* predeclare for signal	*/
-    char *getlogin();			/* to avoid confusion. */
  
     /* Check the number of arguments */
     if (argc < 2) {

--- 27,32 -----
     char psockname[80];			/* phone socket name */
     struct passwd *pw;			/* pointer to password structure */
     int nodaemon(),daemonstarted();	/* predeclare for signal	*/
  
     /* Check the number of arguments */
     if (argc < 2) {
***************
*** 53,60
     }
  
     /* Get my user name from the uid and the passwd file */
!    pw = getpwnam(getlogin());
!    /* pw = getpwuid(getuid()); */
     if (pw == 0) {
        printf("Can't get your login name.");
        _exit(1);

--- 51,57 -----
     }
  
     /* Get my user name from the uid and the passwd file */
!    pw = getpwuid(getuid());
     if (pw == 0) {
        printf("Can't get your login name.");
        _exit(1);
--
Hur, Jinho	Dept of Computer Science, KAIST
uucp: hplabs!kaist!jhhur
csnet: jhhur%kaist at csnet-relay.csnet
-- 
real:	Hur, Jinho	Dept of Computer Science, KAIST
uucp:	..!hplabs!kaist!jhhur
csnet:	jhhur%kaist.csnet at csnet.arpa



More information about the Comp.sources.unix mailing list