if (!(afs_server = getenv("AFSSERVER"))) {
char *home_dir;
FILE *fp;
- int len;
+ int len = 0;
if (!(home_dir = getenv("HOME"))) {
/* Our last chance is the "/.AFSSERVER" file */
if (fp == 0) {
return 0;
}
- fgets(server_name, 128, fp);
- fclose(fp);
} else {
- char pathname[256];
+ char *pathname;
- sprintf(pathname, "%s/%s", home_dir, ".AFSSERVER");
+ len = asprintf(&pathname, "%s/%s", home_dir, ".AFSSERVER");
+ if (len < 0 || pathname == NULL)
+ return 0;
fp = fopen(pathname, "r");
+ free(pathname);
+
if (fp == 0) {
/* Our last chance is the "/.AFSSERVER" file */
fp = fopen("/.AFSSERVER", "r");
return 0;
}
}
- fgets(server_name, 128, fp);
- fclose(fp);
}
- len = strlen(server_name);
+ if (fgets(server_name, 128, fp) != NULL)
+ len = strlen(server_name);
+ fclose(fp);
if (len == 0) {
return 0;
}
null_securityObject = rxnull_NewClientSecurityObject();
conn =
rx_NewConnection(host, htons(AFSCONF_RMTSYSPORT), RMTSYS_SERVICEID,
- null_securityObject, 0);
+ null_securityObject, RX_SECIDX_NULL);
if (!conn) {
printf("Unable to make a new connection\n");
*errorcode = -1;
/* WARNING: The calling program (i.e. klog) MUST be suid-root since we need to
* do a setgroups(2) call with the new pag.... */
-#ifdef AFS_DUX40_ENV
-#pragma weak setpag = afs_setpag
-int
-afs_setpag(void)
-#else
int
setpag(void)
-#endif
{
struct rx_connection *conn;
clientcred creds;
/* Remote pioctl(2) client routine */
-#ifdef AFS_DUX40_ENV
-#pragma weak pioctl = afs_pioctl
-int
-afs_pioctl(char *path, afs_int32 cmd, struct ViceIoctl *data,
- afs_int32 follow)
-#else
int
pioctl(char *path, afs_int32 cmd, struct ViceIoctl *data, afs_int32 follow)
-#endif
{
struct rx_connection *conn;
clientcred creds;
return errorcode;
}
(void)SetClientCreds(&creds, groups);
-#ifdef AFS_OSF_ENV
- if (!ins)
- ins = 1;
-#endif
- if (!(inbuffer = (char *)malloc(ins)))
+ if (!(inbuffer = malloc(ins)))
return (-1); /* helpless here */
if (data->in_size)
memcpy(inbuffer, data->in, data->in_size);