comparison lib-src/gnuslib.c @ 259:11cf20601dec r20-5b28

Import from CVS: tag r20-5b28
author cvs
date Mon, 13 Aug 2007 10:23:02 +0200
parents e45d5e7c476e
children 972bbb6d6ca2
comparison
equal deleted inserted replaced
258:58424f6abf56 259:11cf20601dec
69 #ifdef HAVE_STRING_H 69 #ifdef HAVE_STRING_H
70 #include <string.h> 70 #include <string.h>
71 #endif /* HAVE_STRING_H */ 71 #endif /* HAVE_STRING_H */
72 72
73 #include <arpa/inet.h> 73 #include <arpa/inet.h>
74
75 char *tmpdir = NULL;
74 76
75 char *progname = NULL; 77 char *progname = NULL;
76 78
77 int make_connection(hostarg, portarg, s) 79 int make_connection(hostarg, portarg, s)
78 char *hostarg; 80 char *hostarg;
132 { 134 {
133 int s; /* connected msqid */ 135 int s; /* connected msqid */
134 key_t key; /* message key */ 136 key_t key; /* message key */
135 char buf[GSERV_BUFSZ+1]; /* buffer for filename */ 137 char buf[GSERV_BUFSZ+1]; /* buffer for filename */
136 138
137 sprintf(buf,"/tmp/gsrv%d",(int)geteuid()); 139 sprintf(buf,"%s/gsrv%d",tmpdir,(int)geteuid());
138 creat(buf,0600); 140 creat(buf,0600);
139 if ((key = ftok(buf,1)) == -1) { 141 if ((key = ftok(buf,1)) == -1) {
140 perror(progname); 142 perror(progname);
141 fprintf(stderr, "%s: unable to get ipc key from %s\n", 143 fprintf(stderr, "%s: unable to get ipc key from %s\n",
142 progname, buf); 144 progname, buf);
261 exit(1); 263 exit(1);
262 }; /* if */ 264 }; /* if */
263 265
264 server.sun_family = AF_UNIX; 266 server.sun_family = AF_UNIX;
265 #ifdef HIDE_UNIX_SOCKET 267 #ifdef HIDE_UNIX_SOCKET
266 sprintf(server.sun_path,"/tmp/gsrvdir%d/gsrv",(int)geteuid()); 268 sprintf(server.sun_path,"%s/gsrvdir%d/gsrv",tmpdir,(int)geteuid());
267 #else /* HIDE_UNIX_SOCKET */ 269 #else /* HIDE_UNIX_SOCKET */
268 sprintf(server.sun_path,"/tmp/gsrv%d",(int)geteuid()); 270 sprintf(server.sun_path,"%s/gsrv%d",tmpdir,(int)geteuid());
269 #endif /* HIDE_UNIX_SOCKET */ 271 #endif /* HIDE_UNIX_SOCKET */
270 if (connect(s,(struct sockaddr *)&server,strlen(server.sun_path)+2) < 0) { 272 if (connect(s,(struct sockaddr *)&server,strlen(server.sun_path)+2) < 0) {
271 perror(progname); 273 perror(progname);
272 fprintf(stderr,"%s: unable to connect to local\n",progname); 274 fprintf(stderr,"%s: unable to connect to local\n",progname);
273 exit(1); 275 exit(1);