void StartNonSessionAwareApps(void) { char logtext[256]; int i; for (i = 0; i < non_session_aware_count; i++) { /* * Let the shell parse the stupid args. We need to add an "&" * at the end of the command. We previously allocated an extra * byte for this. */ sprintf (logtext, "Restarting locally : %s\n", non_session_aware_clients[i]); add_log_text (logtext); strcat (non_session_aware_clients[i], "&"); execute_system_command (non_session_aware_clients[i]); free ((char *) non_session_aware_clients[i]); } if (non_session_aware_clients) { free ((char *) non_session_aware_clients); non_session_aware_clients = NULL; } }
void StartDefaultApps (void) { FILE *f; char *buf, *p, filename[128]; const char *home; int buflen, len; /* * First try ~/.xsmstartup, then system.xsm */ home = getenv ("HOME"); if (!home) home = "."; snprintf (filename, sizeof(filename), "%s/.xsmstartup", home); f = fopen (filename, "r"); if (!f) { f = fopen (SYSTEM_INIT_FILE, "r"); if (!f) { printf ("Could not find default apps file. Make sure you did\n"); printf ("a 'make install' in the xsm build directory.\n"); exit (1); } } buf = NULL; buflen = 0; while (getnextline(&buf, &buflen, f)) { char logtext[256]; if (buf[0] == '!') continue; /* a comment */ if ((p = strchr (buf, '\n'))) *p = '\0'; snprintf (logtext, sizeof(logtext), "Starting locally : %s\n", buf); add_log_text (logtext); len = strlen (buf); buf[len] = '&'; buf[len+1] = '\0'; /* let the shell parse the stupid args */ execute_system_command (buf); } if (buf) free (buf); }
void FreeAuthenticationData(int count, IceAuthDataEntry *authDataEntries) { /* Each transport has entries for ICE and XSMP */ char command[256]; int i; for (i = 0; i < count * 2; i++) { free (authDataEntries[i].network_id); free (authDataEntries[i].auth_data); } XtFree ((char *) authDataEntries); snprintf (command, sizeof(command), "iceauth source %s", remAuthFile); execute_system_command (command); remove (remAuthFile); free (addAuthFile); free (remAuthFile); }
Status SetAuthentication(int count, IceListenObj *listenObjs, IceAuthDataEntry **authDataEntries) { FILE *addfp = NULL; FILE *removefp = NULL; const char *path; mode_t original_umask; char command[256]; int i; #ifdef HAVE_MKSTEMP int fd; #endif original_umask = umask (0077); /* disallow non-owner access */ path = getenv ("SM_SAVE_DIR"); if (!path) { path = getenv ("HOME"); if (!path) path = "."; } #ifndef HAVE_MKSTEMP if ((addAuthFile = unique_filename (path, ".xsm")) == NULL) goto bad; if (!(addfp = fopen (addAuthFile, "w"))) goto bad; fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC); if ((remAuthFile = unique_filename (path, ".xsm")) == NULL) goto bad; if (!(removefp = fopen (remAuthFile, "w"))) goto bad; fcntl(fileno(removefp), F_SETFD, FD_CLOEXEC); #else if ((addAuthFile = unique_filename (path, ".xsm", &fd)) == NULL) goto bad; if (!(addfp = fdopen(fd, "wb"))) goto bad; fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC); if ((remAuthFile = unique_filename (path, ".xsm", &fd)) == NULL) goto bad; if (!(removefp = fdopen(fd, "wb"))) goto bad; fcntl(fileno(removefp), F_SETFD, FD_CLOEXEC); #endif if ((*authDataEntries = (IceAuthDataEntry *) XtMalloc ( count * 2 * sizeof (IceAuthDataEntry))) == NULL) goto bad; for (i = 0; i < count * 2; i += 2) { (*authDataEntries)[i].network_id = IceGetListenConnectionString (listenObjs[i/2]); (*authDataEntries)[i].protocol_name = "ICE"; (*authDataEntries)[i].auth_name = "MIT-MAGIC-COOKIE-1"; (*authDataEntries)[i].auth_data = IceGenerateMagicCookie (MAGIC_COOKIE_LEN); (*authDataEntries)[i].auth_data_length = MAGIC_COOKIE_LEN; (*authDataEntries)[i+1].network_id = IceGetListenConnectionString (listenObjs[i/2]); (*authDataEntries)[i+1].protocol_name = "XSMP"; (*authDataEntries)[i+1].auth_name = "MIT-MAGIC-COOKIE-1"; (*authDataEntries)[i+1].auth_data = IceGenerateMagicCookie (MAGIC_COOKIE_LEN); (*authDataEntries)[i+1].auth_data_length = MAGIC_COOKIE_LEN; write_iceauth (addfp, removefp, &(*authDataEntries)[i]); write_iceauth (addfp, removefp, &(*authDataEntries)[i+1]); IceSetPaAuthData (2, &(*authDataEntries)[i]); IceSetHostBasedAuthProc (listenObjs[i/2], HostBasedAuthProc); } fclose (addfp); fclose (removefp); umask (original_umask); snprintf (command, sizeof(command), "iceauth source %s", addAuthFile); execute_system_command (command); remove (addAuthFile); return (1); bad: if (addfp) fclose (addfp); if (removefp) fclose (removefp); if (addAuthFile) { remove (addAuthFile); free (addAuthFile); } if (remAuthFile) { remove (remAuthFile); free (remAuthFile); } return (0); }