Mercurial > hg > xemacs-beta
comparison lib-src/gnuserv.c @ 259:11cf20601dec r20-5b28
Import from CVS: tag r20-5b28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:23:02 +0200 |
parents | 41f2f0e326e9 |
children | 972bbb6d6ca2 |
comparison
equal
deleted
inserted
replaced
258:58424f6abf56 | 259:11cf20601dec |
---|---|
137 ipc_init (struct msgbuf **msgpp) | 137 ipc_init (struct msgbuf **msgpp) |
138 { | 138 { |
139 key_t key; /* messge key */ | 139 key_t key; /* messge key */ |
140 char buf[GSERV_BUFSZ]; /* pathname for key */ | 140 char buf[GSERV_BUFSZ]; /* pathname for key */ |
141 | 141 |
142 sprintf (buf,"/tmp/gsrv%d",(int)geteuid ()); | 142 sprintf (buf,"%s/gsrv%d",tmpdir,(int)geteuid ()); |
143 creat (buf,0600); | 143 creat (buf,0600); |
144 key = ftok (buf,1); | 144 key = ftok (buf,1); |
145 | 145 |
146 if ((ipc_qid = msgget (key,0600|IPC_CREAT)) == -1) | 146 if ((ipc_qid = msgget (key,0600|IPC_CREAT)) == -1) |
147 { | 147 { |
741 exit(1); | 741 exit(1); |
742 } /* if */ | 742 } /* if */ |
743 | 743 |
744 /* Set up address structure for the listen socket. */ | 744 /* Set up address structure for the listen socket. */ |
745 #ifdef HIDE_UNIX_SOCKET | 745 #ifdef HIDE_UNIX_SOCKET |
746 sprintf(server.sun_path,"/tmp/gsrvdir%d",(int)geteuid()); | 746 sprintf(server.sun_path,"%s/gsrvdir%d",tmpdir,(int)geteuid()); |
747 if (mkdir(server.sun_path, 0700) < 0) | 747 if (mkdir(server.sun_path, 0700) < 0) |
748 { | 748 { |
749 /* assume it already exists, and try to set perms */ | 749 /* assume it already exists, and try to set perms */ |
750 if (chmod(server.sun_path, 0700) < 0) | 750 if (chmod(server.sun_path, 0700) < 0) |
751 { | 751 { |
756 } | 756 } |
757 } | 757 } |
758 strcat(server.sun_path,"/gsrv"); | 758 strcat(server.sun_path,"/gsrv"); |
759 unlink(server.sun_path); /* remove old file if it exists */ | 759 unlink(server.sun_path); /* remove old file if it exists */ |
760 #else /* HIDE_UNIX_SOCKET */ | 760 #else /* HIDE_UNIX_SOCKET */ |
761 sprintf(server.sun_path,"/tmp/gsrv%d",(int)geteuid()); | 761 sprintf(server.sun_path,"%s/gsrv%d",tmpdir,(int)geteuid()); |
762 unlink(server.sun_path); /* remove old file if it exists */ | 762 unlink(server.sun_path); /* remove old file if it exists */ |
763 #endif /* HIDE_UNIX_SOCKET */ | 763 #endif /* HIDE_UNIX_SOCKET */ |
764 | 764 |
765 server.sun_family = AF_UNIX; | 765 server.sun_family = AF_UNIX; |
766 #ifdef HAVE_SOCKADDR_SUN_LEN | 766 #ifdef HAVE_SOCKADDR_SUN_LEN |
847 progname = argv[0]; | 847 progname = argv[0]; |
848 | 848 |
849 for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */ | 849 for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */ |
850 ; | 850 ; |
851 | 851 |
852 #ifdef USE_TMPDIR | |
853 tmpdir = getenv("TMPDIR"); | |
854 #endif | |
855 if (!tmpdir) | |
856 tmpdir = "/tmp"; | |
852 #ifdef USE_LITOUT | 857 #ifdef USE_LITOUT |
853 { | 858 { |
854 /* this is to allow ^D to pass to emacs */ | 859 /* this is to allow ^D to pass to emacs */ |
855 int d = LLITOUT; | 860 int d = LLITOUT; |
856 (void) ioctl(fileno(stdout), TIOCLBIS, &d); | 861 (void) ioctl(fileno(stdout), TIOCLBIS, &d); |