这篇教程C++ unsetenv函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中unsetenv函数的典型用法代码示例。如果您正苦于以下问题:C++ unsetenv函数的具体用法?C++ unsetenv怎么用?C++ unsetenv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了unsetenv函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: start_command//.........这里部分代码省略......... close(cmd->in); } if (cmd->no_stderr) dup_devnull(2); else if (need_err) { dup2(fderr[1], 2); close_pair(fderr); } else if (cmd->err > 1) { dup2(cmd->err, 2); close(cmd->err); } if (cmd->no_stdout) dup_devnull(1); else if (cmd->stdout_to_stderr) dup2(2, 1); else if (need_out) { dup2(fdout[1], 1); close_pair(fdout); } else if (cmd->out > 1) { dup2(cmd->out, 1); close(cmd->out); } if (cmd->dir && chdir(cmd->dir)) die_errno("exec '%s': cd to '%s' failed", cmd->argv[0], cmd->dir); if (cmd->env) { for (; *cmd->env; cmd->env++) { if (strchr(*cmd->env, '=')) putenv((char *)*cmd->env); else unsetenv(*cmd->env); } } if (cmd->git_cmd) execv_git_cmd(cmd->argv); else if (cmd->use_shell) execv_shell_cmd(cmd->argv); else sane_execvp(cmd->argv[0], (char *const*) cmd->argv); if (errno == ENOENT) { if (!cmd->silent_exec_failure) error("cannot run %s: %s", cmd->argv[0], strerror(ENOENT)); exit(127); } else { die_errno("cannot exec '%s'", cmd->argv[0]); } } if (cmd->pid < 0) error("cannot fork() for %s: %s", cmd->argv[0], strerror(errno)); else if (cmd->clean_on_exit) mark_child_for_cleanup(cmd->pid); /* * Wait for child's execvp. If the execvp succeeds (or if fork() * failed), EOF is seen immediately by the parent. Otherwise, the * child process sends a single byte. * Note that use of this infrastructure is completely advisory, * therefore, we keep error checks minimal. */ close(notify_pipe[1]); if (read(notify_pipe[0], ¬ify_pipe[1], 1) == 1) {
开发者ID:Carina26,项目名称:git,代码行数:67,
示例2: mainint main(int argc, char ** argv) { FILE *containerimage_fp; FILE *loop_fp; FILE *config_fp; char *containerimage; char *containername; char *containerpath; char *username; char *command; char *tmpdir; char *loop_dev_lock; char *loop_dev_cache; char *loop_dev = 0; char *config_path; char *tmp_config_string; char cwd[PATH_MAX]; int cwd_fd; int tmpdirlock_fd; int containerimage_fd; int loop_dev_lock_fd; int gid_list_count; int retval = 0; uid_t uid; gid_t gid; gid_t *gid_list; pid_t namespace_fork_pid = 0; struct passwd *pw;//****************************************************************************//// Init//****************************************************************************// signal(SIGINT, sighandler); signal(SIGKILL, sighandler); signal(SIGQUIT, sighandler); openlog("Singularity", LOG_CONS | LOG_NDELAY, LOG_LOCAL0); // Get all user/group info uid = getuid(); gid = getgid(); gid_list_count = getgroups(0, NULL); gid_list = (gid_t *) malloc(sizeof(gid_t) * gid_list_count); if ( getgroups(gid_list_count, gid_list) < 0 ) { fprintf(stderr, "ABORT: Could not obtain current supplementary group list: %s/n", strerror(errno)); return(255); } pw = getpwuid(uid); // Check to make sure we are installed correctly if ( seteuid(0) < 0 ) { fprintf(stderr, "ABORT: Check installation, must be performed by root./n"); return(255); } // Lets start off as the calling UID if ( seteuid(uid) < 0 ) { fprintf(stderr, "ABORT: Could not set effective uid to %d: %s/n", uid, strerror(errno)); return(255); } if ( setegid(gid) < 0 ) { fprintf(stderr, "ABORT: Could not set effective gid to %d: %s/n", gid, strerror(errno)); return(255); } username = pw->pw_name; containerimage = getenv("SINGULARITY_IMAGE"); command = getenv("SINGULARITY_COMMAND"); unsetenv("SINGULARITY_COMMAND"); unsetenv("SINGULARITY_EXEC"); config_path = (char *) malloc(strlen(SYSCONFDIR) + 30); snprintf(config_path, strlen(SYSCONFDIR) + 30, "%s/singularity/singularity.conf", SYSCONFDIR); // Figure out where we start if ( (cwd_fd = open(".", O_RDONLY)) < 0 ) { fprintf(stderr, "ABORT: Could not open cwd fd (%s)!/n", strerror(errno)); return(1); } if ( getcwd(cwd, PATH_MAX) == NULL ) { fprintf(stderr, "Could not obtain current directory path: %s/n", strerror(errno)); return(1); } if ( containerimage == NULL ) { fprintf(stderr, "ABORT: SINGULARITY_IMAGE undefined!/n"); return(1); } if ( is_file(containerimage) != 0 ) { fprintf(stderr, "ABORT: Container image path is invalid: %s/n", containerimage); return(1); } if ( is_file(config_path) != 0 ) { fprintf(stderr, "ABORT: Configuration file not found: %s/n", config_path); return(255); }//.........这里部分代码省略.........
开发者ID:ManifoldMike,项目名称:singularity,代码行数:101,
示例3: mymainstatic intmymain(void){ int ret = 0; bool json = false; abs_top_srcdir = getenv("abs_top_srcdir"); if (!abs_top_srcdir) abs_top_srcdir = abs_srcdir "/.."; if (!(driver.config = virQEMUDriverConfigNew(false))) return EXIT_FAILURE; if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE;# define DO_TEST_FULL(name, migrateFrom, migrateFd, expectError, ...) / do { / struct testInfo info = { / name, NULL, migrateFrom, migrateFd, json, expectError / }; / if (!(info.extraFlags = virQEMUCapsNew())) / return EXIT_FAILURE; / virQEMUCapsSetList(info.extraFlags, __VA_ARGS__, QEMU_CAPS_LAST);/ if (virtTestRun("QEMU XML-2-ARGV " name, / testCompareXMLToArgvHelper, &info) < 0) / ret = -1; / virObjectUnref(info.extraFlags); / } while (0)# define DO_TEST(name, expectError, ...) / DO_TEST_FULL(name, NULL, -1, expectError, __VA_ARGS__)# define NONE QEMU_CAPS_LAST /* Unset or set all envvars here that are copied in qemudBuildCommandLine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected * values for these envvars */ setenv("PATH", "/bin", 1); setenv("USER", "test", 1); setenv("LOGNAME", "test", 1); setenv("HOME", "/home/test", 1); unsetenv("TMPDIR"); unsetenv("LD_PRELOAD"); unsetenv("LD_LIBRARY_PATH"); unsetenv("QEMU_AUDIO_DRV"); unsetenv("SDL_AUDIODRIVER"); DO_TEST("qemu-ns-domain", false, NONE); DO_TEST("qemu-ns-domain-ns0", false, NONE); DO_TEST("qemu-ns-domain-commandline", false, NONE); DO_TEST("qemu-ns-domain-commandline-ns0", false, NONE); DO_TEST("qemu-ns-commandline", false, NONE); DO_TEST("qemu-ns-commandline-ns0", false, NONE); DO_TEST("qemu-ns-commandline-ns1", false, NONE); virObjectUnref(driver.config); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;}
开发者ID:lixingchen12138,项目名称:libvmi-volatility-master,代码行数:63,
示例4: locale_setupint locale_setup(void) { char *variables[_VARIABLE_MAX] = {}; int r = 0, i; if (detect_container(NULL) <= 0) { r = parse_env_file("/proc/cmdline", WHITESPACE, "locale.LANG", &variables[VARIABLE_LANG], "locale.LANGUAGE", &variables[VARIABLE_LANGUAGE], "locale.LC_CTYPE", &variables[VARIABLE_LC_CTYPE], "locale.LC_NUMERIC", &variables[VARIABLE_LC_NUMERIC], "locale.LC_TIME", &variables[VARIABLE_LC_TIME], "locale.LC_COLLATE", &variables[VARIABLE_LC_COLLATE], "locale.LC_MONETARY", &variables[VARIABLE_LC_MONETARY], "locale.LC_MESSAGES", &variables[VARIABLE_LC_MESSAGES], "locale.LC_PAPER", &variables[VARIABLE_LC_PAPER], "locale.LC_NAME", &variables[VARIABLE_LC_NAME], "locale.LC_ADDRESS", &variables[VARIABLE_LC_ADDRESS], "locale.LC_TELEPHONE", &variables[VARIABLE_LC_TELEPHONE], "locale.LC_MEASUREMENT", &variables[VARIABLE_LC_MEASUREMENT], "locale.LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION], NULL); if (r < 0 && r != -ENOENT) log_warning("Failed to read /proc/cmdline: %s", strerror(-r)); } /* Hmm, nothing set on the kernel cmd line? Then let's * try /etc/locale.conf */ if (r <= 0) { r = parse_env_file("/etc/locale.conf", NEWLINE, "LANG", &variables[VARIABLE_LANG], "LANGUAGE", &variables[VARIABLE_LANGUAGE], "LC_CTYPE", &variables[VARIABLE_LC_CTYPE], "LC_NUMERIC", &variables[VARIABLE_LC_NUMERIC], "LC_TIME", &variables[VARIABLE_LC_TIME], "LC_COLLATE", &variables[VARIABLE_LC_COLLATE], "LC_MONETARY", &variables[VARIABLE_LC_MONETARY], "LC_MESSAGES", &variables[VARIABLE_LC_MESSAGES], "LC_PAPER", &variables[VARIABLE_LC_PAPER], "LC_NAME", &variables[VARIABLE_LC_NAME], "LC_ADDRESS", &variables[VARIABLE_LC_ADDRESS], "LC_TELEPHONE", &variables[VARIABLE_LC_TELEPHONE], "LC_MEASUREMENT", &variables[VARIABLE_LC_MEASUREMENT], "LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION], NULL); if (r < 0 && r != -ENOENT) log_warning("Failed to read /etc/locale.conf: %s", strerror(-r)); } if (r <= 0 && (r = parse_env_file("/etc/default/locale", NEWLINE, "LANG", &variables[VARIABLE_LANG], "LC_CTYPE", &variables[VARIABLE_LC_CTYPE], "LC_NUMERIC", &variables[VARIABLE_LC_NUMERIC], "LC_TIME", &variables[VARIABLE_LC_TIME], "LC_COLLATE", &variables[VARIABLE_LC_COLLATE], "LC_MONETARY", &variables[VARIABLE_LC_MONETARY], "LC_MESSAGES", &variables[VARIABLE_LC_MESSAGES], "LC_PAPER", &variables[VARIABLE_LC_PAPER], "LC_NAME", &variables[VARIABLE_LC_NAME], "LC_ADDRESS", &variables[VARIABLE_LC_ADDRESS], "LC_TELEPHONE", &variables[VARIABLE_LC_TELEPHONE], "LC_MEASUREMENT", &variables[VARIABLE_LC_MEASUREMENT], "LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION], NULL)) < 0) { if (r != -ENOENT) log_warning("Failed to read /etc/default/locale: %s", strerror(-r)); } if (!variables[VARIABLE_LANG]) { variables[VARIABLE_LANG] = strdup("C"); if (!variables[VARIABLE_LANG]) { r = -ENOMEM; goto finish; } } for (i = 0; i < _VARIABLE_MAX; i++) { if (variables[i]) { if (setenv(variable_names[i], variables[i], 1) < 0) { r = -errno; goto finish; } } else unsetenv(variable_names[i]); } r = 0;finish: for (i = 0; i < _VARIABLE_MAX; i++) free(variables[i]); return r;}
开发者ID:linuxmint,项目名称:systemd-rosa,代码行数:97,
示例5: test_str_screen_widthvoidtest_str_screen_width (void){ struct winsize winsize; int pty, pts; size_t len = 0; TEST_FUNCTION ("nih_str_screen_width"); unsetenv ("COLUMNS"); winsize.ws_row = 24; winsize.ws_col = 40; winsize.ws_xpixel = 0; winsize.ws_ypixel = 0; openpty (&pty, &pts, NULL, NULL, &winsize); /* Check that we can obtain the width of a screen, where one * is available. It should match the number of columns in the * pty we run this within. */ TEST_FEATURE ("with screen width"); TEST_DIVERT_STDOUT_FD (pts) { len = nih_str_screen_width (); } TEST_EQ (len, 40); /* Check that the COLUMNS environment variable overrides the width * of the screen that we detect. */ TEST_FEATURE ("with COLUMNS variable"); putenv ("COLUMNS=30"); TEST_DIVERT_STDOUT_FD (pts) { len = nih_str_screen_width (); } TEST_EQ (len, 30); /* Check that we ignore a COLUMNS variable that's not an integer */ TEST_FEATURE ("with illegal COLUMNS variable"); putenv ("COLUMNS=30pt"); TEST_DIVERT_STDOUT_FD (pts) { len = nih_str_screen_width (); } TEST_EQ (len, 40); unsetenv ("COLUMNS"); close (pts); close (pty); /* Check that we fallback to assuming 80 columns if we don't have * any luck with either the tty or COLUMNS variable. */ TEST_FEATURE ("with fallback to 80 columns"); pts = open ("/dev/null", O_RDWR | O_NOCTTY); TEST_DIVERT_STDOUT_FD (pts) { len = nih_str_screen_width (); } TEST_EQ (len, 80); close (pts);}
开发者ID:cmjonze,项目名称:libnih,代码行数:67,
示例6: TclCygwinPutenvstatic voidTclCygwinPutenv( const char *str){ char *name, *value; /* * Get the name and value, so that we can change the environment variable * for Windows. */ name = alloca(strlen(str) + 1); strcpy(name, str); for (value=name ; *value!='=' && *value!='/0' ; ++value) { /* Empty body */ } if (*value == '/0') { /* Can't happen. */ return; } *value = '/0'; ++value; if (*value == '/0') { value = NULL; } /* * Set the cygwin environment variable. */#undef putenv if (value == NULL) { unsetenv(name); } else { putenv(str); } /* * Before changing the environment variable in Windows, if this is PATH, * we need to convert the value back to a Windows style path. * * FIXME: The calling program may know it is running under windows, and * may have set the path to a Windows path, or, worse, appended or * prepended a Windows path to PATH. */ if (strcmp(name, "PATH") != 0) { /* * If this is Path, eliminate any PATH variable, to prevent any * confusion. */ if (strcmp(name, "Path") == 0) { SetEnvironmentVariable("PATH", NULL); unsetenv("PATH"); } SetEnvironmentVariable(name, value); } else { char *buf; /* * Eliminate any Path variable, to prevent any confusion. */ SetEnvironmentVariable("Path", NULL); unsetenv("Path"); if (value == NULL) { buf = NULL; } else { int size; size = cygwin_posix_to_win32_path_list_buf_size(value); buf = alloca(size + 1); cygwin_posix_to_win32_path_list(value, buf); } SetEnvironmentVariable(name, buf); }}
开发者ID:lmiadowicz,项目名称:tcl,代码行数:81,
示例7: main/***************************************************************************** * main: parse command line, start interface and spawn threads. *****************************************************************************/int main( int i_argc, const char *ppsz_argv[] ){ /* The so-called POSIX-compliant MacOS X reportedly processes SIGPIPE even * if it is blocked in all thread. * Note: this is NOT an excuse for not protecting against SIGPIPE. If * LibVLC runs outside of VLC, we cannot rely on this code snippet. */ signal (SIGPIPE, SIG_IGN); /* Restore SIGCHLD in case our parent process ignores it. */ signal (SIGCHLD, SIG_DFL);#ifndef NDEBUG /* Activate malloc checking routines to detect heap corruptions. */ setenv ("MALLOC_CHECK_", "2", 1); /* Disable the ugly Gnome crash dialog so that we properly segfault */ setenv ("GNOME_DISABLE_CRASH_DIALOG", "1", 1);#endif#ifdef TOP_BUILDDIR setenv ("VLC_PLUGIN_PATH", TOP_BUILDDIR"/modules", 1); setenv ("VLC_DATA_PATH", TOP_SRCDIR"/share", 1);#endif /* Clear the X.Org startup notification ID. Otherwise the UI might try to * change the environment while the process is multi-threaded. That could * crash. Screw you X.Org. Next time write a thread-safe specification. */ unsetenv ("DESKTOP_STARTUP_ID");#ifndef ALLOW_RUN_AS_ROOT if (geteuid () == 0) { fprintf (stderr, "VLC is not supposed to be run as root. Sorry./n" "If you need to use real-time priorities and/or privileged TCP ports/n" "you can use %s-wrapper (make sure it is Set-UID root and/n" "cannot be run by non-trusted users first)./n", ppsz_argv[0]); return 1; }#endif setlocale (LC_ALL, ""); if (isatty (STDERR_FILENO)) /* This message clutters error logs. It is printed only on a TTY. * Fortunately, LibVLC prints version info with -vv anyway. */ fprintf (stderr, "VLC media player %s (revision %s)/n", libvlc_get_version(), libvlc_get_changeset()); sigset_t set; sigemptyset (&set); /* VLC uses sigwait() to dequeue interesting signals. * For this to work, those signals must be blocked in all threads, * including the thread calling sigwait() (see the man page for details). * * There are two advantages to sigwait() over traditional signal handlers: * - delivery is synchronous: no need to worry about async-safety, * - EINTR is not generated: other threads need not handle that error. * That being said, some LibVLC programs do not use sigwait(). Therefore * EINTR must still be handled cleanly, notably from poll() calls. * * Signals that request a clean shutdown, and force an unclean shutdown * if they are triggered again 2+ seconds later. * We have to handle SIGTERM cleanly because of daemon mode. */ sigaddset (&set, SIGINT); sigaddset (&set, SIGHUP); sigaddset (&set, SIGQUIT); sigaddset (&set, SIGTERM); /* SIGPIPE can happen and would crash the process. On modern systems, * the MSG_NOSIGNAL flag protects socket write operations against SIGPIPE. * But we still need to block SIGPIPE when: * - writing to pipes, * - using write() instead of send() for code not specific to sockets. * LibVLC code assumes that SIGPIPE is blocked. Other LibVLC applications * shall block it (or handle it somehow) too. */ sigaddset (&set, SIGPIPE); /* SIGCHLD must be dequeued to clean up zombie child processes. * Furthermore the handler must not be set to SIG_IGN (see above). * We cannot pragmatically handle EINTR, short reads and short writes * in every code paths (including underlying libraries). So we just * block SIGCHLD in all threads, and dequeue it below. */ sigaddset (&set, SIGCHLD); /* Block all these signals */ pthread_t self = pthread_self (); pthread_sigmask (SIG_SETMASK, &set, NULL); const char *argv[i_argc + 3]; int argc = 0; argv[argc++] = "--no-ignore-config"; argv[argc++] = "--media-library"; argv[argc++] = "--stats"; ppsz_argv++; i_argc--; /* skip executable path *///.........这里部分代码省略.........
开发者ID:Aseeker,项目名称:vlc,代码行数:101,
示例8: MinidumpCallback//.........这里部分代码省略......... close(fd); }#endif }#if defined(XP_WIN32) XP_CHAR cmdLine[CMDLINE_SIZE]; size = CMDLINE_SIZE; p = Concat(cmdLine, L"/"", &size); p = Concat(p, crashReporterPath, &size); p = Concat(p, L"/" /"", &size); p = Concat(p, minidumpPath, &size); Concat(p, L"/"", &size); if (!crashReporterAPIData->IsEmpty()) { // write out API data HANDLE hFile = CreateFile(extraDataPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile != INVALID_HANDLE_VALUE) { DWORD nBytes; WriteFile(hFile, crashReporterAPIData->get(), crashReporterAPIData->Length(), &nBytes, NULL); WriteFile(hFile, kCrashTimeParameter, kCrashTimeParameterLen, &nBytes, NULL); WriteFile(hFile, crashTimeString, crashTimeStringLen, &nBytes, NULL); WriteFile(hFile, "/n", 1, &nBytes, NULL); if (timeSinceLastCrash != 0) { WriteFile(hFile, kTimeSinceLastCrashParameter, kTimeSinceLastCrashParameterLen, &nBytes, NULL); WriteFile(hFile, timeSinceLastCrashString, timeSinceLastCrashStringLen, &nBytes, NULL); WriteFile(hFile, "/n", 1, &nBytes, NULL); } CloseHandle(hFile); } } if (!doReport) { return returnValue; } STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWNORMAL; ZeroMemory(&pi, sizeof(pi)); if (CreateProcess(NULL, (LPWSTR)cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); } // we're not really in a position to do anything if the CreateProcess fails TerminateProcess(GetCurrentProcess(), 1);#elif defined(XP_UNIX) if (!crashReporterAPIData->IsEmpty()) { // write out API data int fd = open(extraDataPath, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd != -1) { // not much we can do in case of error write(fd, crashReporterAPIData->get(), crashReporterAPIData->Length()); write(fd, kCrashTimeParameter, kCrashTimeParameterLen); write(fd, crashTimeString, crashTimeStringLen); write(fd, "/n", 1); if (timeSinceLastCrash != 0) { write(fd, kTimeSinceLastCrashParameter,kTimeSinceLastCrashParameterLen); write(fd, timeSinceLastCrashString, timeSinceLastCrashStringLen); write(fd, "/n", 1); } close (fd); } } if (!doReport) { return returnValue; } pid_t pid = fork(); if (pid == -1) return false; else if (pid == 0) { // need to clobber this, as libcurl might load NSS, // and we want it to load the system NSS. unsetenv("LD_LIBRARY_PATH"); (void) execl(crashReporterPath, crashReporterPath, minidumpPath, (char*)0); _exit(1); }#endif return returnValue;}
开发者ID:fortunto2,项目名称:celtx,代码行数:101,
示例9: mainint main(int argc, char **argv){ char **args; char *cmd; int i, match; FILE *f; char *cobalt_config_file; char line[1024]; char python_exe[80]; char poss_exe[80]; char diag[80]; strncpy(python_exe, "/usr/bin/python", 80); unsetenv("IFS"); unsetenv("LD_PRELOAD"); unsetenv("LD_LIBRARY_PATH"); if (strlen(PYTHONPATH) > 0) { setenv("PYTHONPATH", PYTHONPATH, 1); } else { unsetenv("PYTHONPATH"); } /* To disable the user's ability to override the default configuration file, uncomment the following line. In addition, the argument processing code below should be modfied to strip the --config-files option from the arguments passed on to the python program. */ /* unsetenv("COBALT_CONFIG_FILES"); */ /* grab the python executable from the cobalt.conf file. This should ultimately * be handled by a configure script. * --PMR */ cobalt_config_file = getenv("COBALT_CONFIG_FILES"); if (cobalt_config_file == NULL){ cobalt_config_file = "/etc/cobalt.conf"; } f = fopen(cobalt_config_file, "r"); if(f == NULL){ perror(argv[0]); return 1; } while ((fgets(line, 1024 ,f)) != NULL){ match = sscanf(line, "[%[^]]]", diag); if (match && (!strncmp(diag, "components", 80))){ break; } } while ((fgets(line, 1024 ,f)) != NULL){ match = sscanf(line, "%[^=]=%s", diag, poss_exe); if (match != 2){ match = sscanf(line, "%[^:]:%s", diag, poss_exe); } strip_whitespace(diag); strip_whitespace(poss_exe); if (match && (!strncmp(diag, "python", 80))){ strncpy(python_exe, poss_exe, 80); break; } if (sscanf(line, "[%[^]]]", diag)) break; } fclose(f); putenv("SSS_WRAPPER=1"); args = malloc((argc+3) * sizeof(char *)); /*prepend the python override*/ args[0] = python_exe; args[1] = "-E"; for (i=1;i<argc;i++) args[i+2] = argv[i]; args[i+2] = NULL; if ( ( cmd = basename(argv[0]) ) == NULL ) { perror(argv[0]); return 1; } if (asprintf(&args[2], "%s/%s.py", PROGPREFIX, cmd) == -1) { perror(argv[0]); return 1; } /*for (i=0;i<argc+3;++i){ printf("%s ", args[i]); } printf("/n");*/ if (execv(args[0], args)) { perror(argv[0]); return 1; } return 0;}
开发者ID:benmcclelland,项目名称:cobalt-orcm,代码行数:89,
示例10: wlc_initWLC_API boolwlc_init(const struct wlc_interface *interface, int argc, char *argv[]){ assert(interface); if (!interface) die("no wlc_interface was given"); if (wlc.display) return true; memset(&wlc, 0, sizeof(wlc)); wl_log_set_handler_server(wl_cb_log); for (int i = 1; i < argc; ++i) { if (chck_cstreq(argv[i], "--log")) { if (i + 1 >= argc) die("--log takes an argument (filename)"); wlc_set_log_file(fopen(argv[++i], "a")); } } unsetenv("TERM"); const char *x11display = getenv("DISPLAY"); bool privilidged = false; const bool has_logind = wlc_logind_available(); if (getuid() != geteuid() || getgid() != getegid()) { wlc_log(WLC_LOG_INFO, "Doing work on SUID/SGID side and dropping permissions"); privilidged = true; } else if (getuid() == 0) { die("Do not run wlc compositor as root"); } else if (!x11display && !has_logind && access("/dev/input/event0", R_OK | W_OK) != 0) { die("Not running from X11 and no access to /dev/input/event0 or logind available"); }#ifndef NDEBUG { struct sigaction action = { .sa_handler = backtrace }; sigaction(SIGABRT, &action, NULL); sigaction(SIGSEGV, &action, NULL); // XXX: Some weird sigfpes seems to come when running // wlc compositor inside wlc compositor (X11 backend). // Seems to be caused by resolution changes and mouse clicks. // Gather more information about this later and see what's going on. if (!getenv("WAYLAND_DISPLAY")) fpesetup(&action); }#endif int vt = 0;#ifdef HAS_LOGIND // Init logind if we are not running as SUID. // We need event loop for logind to work, and thus we won't allow it on SUID process. if (!privilidged && !x11display && has_logind) { if (!(wlc.display = wl_display_create())) die("Failed to create wayland display"); if (!(vt = wlc_logind_init("seat0"))) die("Failed to init logind"); }#else (void)privilidged;#endif if (!x11display) wlc_tty_init(vt); // -- we open tty before dropping permissions // so the fd process can also handle cleanup in case of crash // if logind initialized correctly, fd process does nothing but handle crash. { struct wl_display *display = wlc.display; wlc.display = NULL; wlc_fd_init(argc, argv, (vt != 0)); wlc.display = display; } // -- permissions are now dropped wl_signal_init(&wlc.signals.terminate); wl_signal_init(&wlc.signals.activate); wl_signal_init(&wlc.signals.compositor); wl_signal_init(&wlc.signals.focus); wl_signal_init(&wlc.signals.surface); wl_signal_init(&wlc.signals.input); wl_signal_init(&wlc.signals.output); wl_signal_init(&wlc.signals.render); wl_signal_init(&wlc.signals.xwayland); wl_signal_add(&wlc.signals.compositor, &compositor_listener); if (!wlc_resources_init()) die("Failed to init resource manager");//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:wlc,代码行数:101,
示例11: start_stop_daemon//.........这里部分代码省略......... progress = true; break; case 'R': /* --retry <schedule>|<timeout> */ retry = optarg; break; case 'S': /* --start */ start = true; break; case 'b': /* --background */ background = true; break; case 'c': /* --chuid <username>|<uid> */ /* DEPRECATED */ ewarn("WARNING: -c/--chuid is deprecated and will be removed in the future, please use -u/--user instead"); case 'u': /* --user <username>|<uid> */ { p = optarg; tmp = strsep(&p, ":"); changeuser = xstrdup(tmp); if (sscanf(tmp, "%d", &tid) != 1) pw = getpwnam(tmp); else pw = getpwuid((uid_t)tid); if (pw == NULL) eerrorx("%s: user `%s' not found", applet, tmp); uid = pw->pw_uid; home = pw->pw_dir; unsetenv("HOME"); if (pw->pw_dir) setenv("HOME", pw->pw_dir, 1); unsetenv("USER"); if (pw->pw_name) setenv("USER", pw->pw_name, 1); if (gid == 0) gid = pw->pw_gid; if (p) { tmp = strsep (&p, ":"); if (sscanf(tmp, "%d", &tid) != 1) gr = getgrnam(tmp); else gr = getgrgid((gid_t) tid); if (gr == NULL) eerrorx("%s: group `%s'" " not found", applet, tmp); gid = gr->gr_gid; } } break; case 'd': /* --chdir /new/dir */ ch_dir = optarg; break; case 'e': /* --env */ putenv(optarg); break;
开发者ID:ccxcz,项目名称:openrc-1,代码行数:66,
示例12: multiboot_execstatic intmultiboot_exec(struct preloaded_file *fp){ vm_offset_t module_start, last_addr, metadata_size; vm_offset_t modulep, kernend, entry; struct file_metadata *md; Elf_Ehdr *ehdr; struct multiboot_info *mb_info = NULL; struct multiboot_mod_list *mb_mod = NULL; char *cmdline = NULL; size_t len; int error, mod_num; /* * Don't pass the memory size found by the bootloader, the memory * available to Dom0 will be lower than that. */ unsetenv("smbios.memory.enabled"); /* Allocate the multiboot struct and fill the basic details. */ mb_info = malloc(sizeof(struct multiboot_info)); if (mb_info == NULL) { error = ENOMEM; goto error; } bzero(mb_info, sizeof(struct multiboot_info)); mb_info->flags = MULTIBOOT_INFO_MEMORY|MULTIBOOT_INFO_BOOT_LOADER_NAME; mb_info->mem_lower = bios_basemem / 1024; mb_info->mem_upper = bios_extmem / 1024; mb_info->boot_loader_name = VTOP(mbl_name); /* Set the Xen command line. */ if (fp->f_args == NULL) { /* Add the Xen command line if it is set. */ cmdline = getenv("xen_cmdline"); if (cmdline != NULL) { fp->f_args = strdup(cmdline); if (fp->f_args == NULL) { error = ENOMEM; goto error; } } } if (fp->f_args != NULL) { len = strlen(fp->f_name) + 1 + strlen(fp->f_args) + 1; cmdline = malloc(len); if (cmdline == NULL) { error = ENOMEM; goto error; } snprintf(cmdline, len, "%s %s", fp->f_name, fp->f_args); mb_info->cmdline = VTOP(cmdline); mb_info->flags |= MULTIBOOT_INFO_CMDLINE; } /* Find the entry point of the Xen kernel and save it for later */ if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { printf("Unable to find %s entry point/n", fp->f_name); error = EINVAL; goto error; } ehdr = (Elf_Ehdr *)&(md->md_data); entry = ehdr->e_entry & 0xffffff; /* * Prepare the multiboot module list, Xen assumes the first * module is the Dom0 kernel, and the second one is the initramfs. * This is not optimal for FreeBSD, that doesn't have a initramfs * but instead loads modules dynamically and creates the metadata * info on-the-fly. * * As expected, the first multiboot module is going to be the * FreeBSD kernel loaded as a raw file. The second module is going * to contain the metadata info and the loaded modules. * * On native FreeBSD loads all the modules and then places the * metadata info at the end, but this is painful when running on Xen, * because it relocates the second multiboot module wherever it * likes. In order to workaround this limitation the metadata * information is placed at the start of the second module and * the original modulep value is saved together with the other * metadata, so we can relocate everything. * * Native layout: * fp->f_addr + fp->f_size * +---------+----------------+------------+ * | | | | * | Kernel | Modules | Metadata | * | | | | * +---------+----------------+------------+ * fp->f_addr modulep kernend * * Xen layout: * * Initial: * fp->f_addr + fp->f_size * +---------+----------+----------------+------------+ * | | | | | * | Kernel | Reserved | Modules | Metadata | * | | | | dry run |//.........这里部分代码省略.........
开发者ID:2trill2spill,项目名称:freebsd,代码行数:101,
示例13: main//.........这里部分代码省略......... if (!(mdb.m_flags & MDB_FL_EXEC)) { warn("term init failed: command-line editing " "and prompt will not be available/n"); } } else { in_io = mdb.m_term; } } mdb.m_in = mdb_iob_create(in_io, MDB_IOB_RDONLY); if (mdb.m_term != NULL) { mdb_iob_setpager(mdb.m_out, mdb.m_term); if (mdb.m_flags & MDB_FL_PAGER) mdb_iob_setflags(mdb.m_out, MDB_IOB_PGENABLE); else mdb_iob_clrflags(mdb.m_out, MDB_IOB_PGENABLE); } else if (ttylike) mdb_iob_setflags(mdb.m_in, MDB_IOB_TTYLIKE); else mdb_iob_setbuf(mdb.m_in, mdb_alloc(1, UM_SLEEP), 1); mdb_pservice_init(); mdb_lex_reset(); if ((mdb.m_shell = getenv("SHELL")) == NULL) mdb.m_shell = "/bin/sh"; /* * If the debugger state is to be inherited from a previous instance, * restore it now prior to path evaluation so that %R is updated. */ if ((p = getenv(MDB_CONFIG_ENV_VAR)) != NULL) { mdb_set_config(p); (void) unsetenv(MDB_CONFIG_ENV_VAR); } /* * Path evaluation part 1: Create the initial module path to allow * the target constructor to load a support module. Then expand * any command-line arguments that modify the paths. */ if (Iflag != NULL) mdb_set_ipath(Iflag); else mdb_set_ipath(MDB_DEF_IPATH); if (Lflag != NULL) mdb_set_lpath(Lflag); else mdb_set_lpath(MDB_DEF_LPATH); if (mdb_get_prompt() == NULL && !(mdb.m_flags & MDB_FL_ADB)) (void) mdb_set_prompt(MDB_DEF_PROMPT); if (tgt_ctor == mdb_kvm_tgt_create) { if (pidarg != NULL) { warn("-p and -k options are mutually exclusive/n"); terminate(2); } if (tgt_argc == 0) tgt_argv[tgt_argc++] = "/dev/ksyms"; if (tgt_argc == 1 && strisnum(tgt_argv[0]) == 0) { if (mdb.m_tgtflags & MDB_TGT_F_ALLOWIO) tgt_argv[tgt_argc++] = "/dev/allkmem"; else
开发者ID:kele,项目名称:illumos-fsd,代码行数:67,
示例14: main/* * Any Postgres server process begins execution here. */intmain(int argc, char *argv[]){ bool do_check_root = true; progname = get_progname(argv[0]); /* * Platform-specific startup hacks */ startup_hacks(progname); /* * Remember the physical location of the initially given argv[] array for * possible use by ps display. On some platforms, the argv[] storage must * be overwritten in order to set the process title for ps. In such cases * save_ps_display_args makes and returns a new copy of the argv[] array. * * save_ps_display_args may also move the environment strings to make * extra room. Therefore this should be done as early as possible during * startup, to avoid entanglements with code that might save a getenv() * result pointer. */ argv = save_ps_display_args(argc, argv); /* * If supported on the current platform, set up a handler to be called if * the backend/postmaster crashes with a fatal signal or exception. */#if defined(WIN32) && defined(HAVE_MINIDUMP_TYPE) pgwin32_install_crashdump_handler();#endif /* * Fire up essential subsystems: error and memory management * * Code after this point is allowed to use elog/ereport, though * localization of messages may not work right away, and messages won't go * anywhere but stderr until GUC settings get loaded. */ MemoryContextInit(); /* * Set up locale information from environment. Note that LC_CTYPE and * LC_COLLATE will be overridden later from pg_control if we are in an * already-initialized database. We set them here so that they will be * available to fill pg_control during initdb. LC_MESSAGES will get set * later during GUC option processing, but we set it here to allow startup * error messages to be localized. */ set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("postgres"));#ifdef WIN32 /* * Windows uses codepages rather than the environment, so we work around * that by querying the environment explicitly first for LC_COLLATE and * LC_CTYPE. We have to do this because initdb passes those values in the * environment. If there is nothing there we fall back on the codepage. */ { char *env_locale; if ((env_locale = getenv("LC_COLLATE")) != NULL) init_locale("LC_COLLATE", LC_COLLATE, env_locale); else init_locale("LC_COLLATE", LC_COLLATE, ""); if ((env_locale = getenv("LC_CTYPE")) != NULL) init_locale("LC_CTYPE", LC_CTYPE, env_locale); else init_locale("LC_CTYPE", LC_CTYPE, ""); }#else init_locale("LC_COLLATE", LC_COLLATE, ""); init_locale("LC_CTYPE", LC_CTYPE, "");#endif#ifdef LC_MESSAGES init_locale("LC_MESSAGES", LC_MESSAGES, "");#endif /* * We keep these set to "C" always, except transiently in pg_locale.c; see * that file for explanations. */ init_locale("LC_MONETARY", LC_MONETARY, "C"); init_locale("LC_NUMERIC", LC_NUMERIC, "C"); init_locale("LC_TIME", LC_TIME, "C"); /* * Now that we have absorbed as much as we wish to from the locale * environment, remove any LC_ALL setting, so that the environment * variables installed by pg_perm_setlocale have force. */ unsetenv("LC_ALL");//.........这里部分代码省略.........
开发者ID:ArgenBarbie,项目名称:postgresql-9.5.0,代码行数:101,
示例15: __attribute__int __attribute__ ((constructor)) initfunc(){ int idfd, len; char idbuf[20]; unsetenv("LD_PRELOAD"); fprintf(stderr, "shmoverride constructor running/n"); real_shmat = dlsym(RTLD_NEXT, "shmat"); real_shmctl = dlsym(RTLD_NEXT, "shmctl"); real_shmdt = dlsym(RTLD_NEXT, "shmdt"); if (!real_shmat || !real_shmctl || !real_shmdt) { perror("shmoverride: missing shm API"); exit(1); } addr_list = list_new();#ifdef XENCTRL_HAS_XC_INTERFACE xc_hnd = xc_interface_open(NULL, NULL, 0); if (!xc_hnd) {#else xc_hnd = xc_interface_open(); if (xc_hnd < 0) {#endif perror("shmoverride xc_interface_open"); return 0; //allow it to run when not under Xen } idfd = open(SHMID_FILENAME, O_WRONLY | O_CREAT | O_EXCL, 0600); if (idfd < 0) { perror("shmoverride creating " SHMID_FILENAME); xc_interface_close(xc_hnd); return 0; } local_shmid = shmget(IPC_PRIVATE, SHM_CMD_NUM_PAGES * 4096, IPC_CREAT | 0700); if (local_shmid == -1) { unlink(SHMID_FILENAME); perror("shmoverride shmget"); exit(1); } sprintf(idbuf, "%d", local_shmid); len = strlen(idbuf); if (write(idfd, idbuf, len) != len) { unlink(SHMID_FILENAME); perror("shmoverride writing " SHMID_FILENAME); exit(1); } if (close(idfd) < 0) { unlink(SHMID_FILENAME); perror("shmoverride closing " SHMID_FILENAME); exit(1); } cmd_pages = real_shmat(local_shmid, 0, 0); if (!cmd_pages) { unlink(SHMID_FILENAME); perror("real_shmat"); exit(1); } cmd_pages->shmid = local_shmid; return 0;}int __attribute__ ((destructor)) descfunc(){ if (cmd_pages) { real_shmdt(cmd_pages); real_shmctl(local_shmid, IPC_RMID, 0); unlink(SHMID_FILENAME); } return 0;}
开发者ID:WetwareLabs,项目名称:qubes-gui-daemon,代码行数:69,
示例16: execute_java_class//.........这里部分代码省略......... for (arg = args; *arg != NULL; arg++) { *p++ = ' '; p = shell_quote_copy (p, *arg); } *p++ = '/0'; /* Ensure command_length was correctly calculated. */ if (p - command > command_length) abort (); if (verbose) printf ("%s/n", command); argv[0] = "/bin/sh"; argv[1] = "-c"; argv[2] = command; argv[3] = NULL; err = executer (java, "/bin/sh", argv, private_data); freesa (command); /* Reset CLASSPATH. */ reset_classpath (old_classpath); goto done1; } } /* Unset the JAVA_HOME environment variable. */ old_JAVA_HOME = getenv ("JAVA_HOME"); if (old_JAVA_HOME != NULL) { old_JAVA_HOME = xstrdup (old_JAVA_HOME); unsetenv ("JAVA_HOME"); } { static bool gij_tested; static bool gij_present; if (!gij_tested) { /* Test for presence of gij: "gij --version > /dev/null" */ char *argv[3]; int exitstatus; argv[0] = "gij"; argv[1] = "--version"; argv[2] = NULL; exitstatus = execute ("gij", "gij", argv, false, false, true, true, true, false); gij_present = (exitstatus == 0); gij_tested = true; } if (gij_present) { char *old_classpath; char **argv = (char **) xallocsa ((2 + nargs + 1) * sizeof (char *)); unsigned int i; /* Set CLASSPATH. */ old_classpath = set_classpath (classpaths, classpaths_count, use_minimal_classpath, verbose);
开发者ID:Thor1Khan,项目名称:gettext,代码行数:66,
示例17: py2app_setPythonPathstatic void py2app_setPythonPath(void) { CFMutableArrayRef paths; CFURLRef resDir; CFStringRef resPath; CFArrayRef resPackages; CFDictionaryRef options; paths = py2app_CFArrayCreateMutable(NULL, 0, py2app_kCFTypeArrayCallBacks); resDir = py2app_CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); resPath = pathFromURL(resDir); py2app_CFArrayAppendValue(paths, resPath); py2app_CFRelease(resPath); resPackages = py2app_getKey("PyResourcePackages"); if (resPackages) { int i; int cnt = py2app_CFArrayGetCount(resPackages); for (i = 0; i < cnt; i++) { resPath = tildeExpand(py2app_CFArrayGetValueAtIndex(resPackages, i)); if (py2app_CFStringGetLength(resPath)) { if (py2app_CFStringGetCharacterAtIndex(resPath, 0) != '/') { CFURLRef absURL = py2app_CFURLCreateWithString( NULL, resPath, resDir); py2app_CFRelease(resPath); resPath = pathFromURL(absURL); py2app_CFRelease(absURL); } py2app_CFArrayAppendValue(paths, resPath); } py2app_CFRelease(resPath); } } py2app_CFRelease(resDir); options = py2app_getKey("PyOptions"); if (options) { CFBooleanRef use_pythonpath; CFNumberRef optimize; use_pythonpath = py2app_CFDictionaryGetValue( options, py2app_CFSTR("use_pythonpath")); if (use_pythonpath && py2app_CFBooleanGetValue(use_pythonpath)) { char *ppath = getenv("PYTHONPATH"); if (ppath) { CFArrayRef oldPath; oldPath = py2app_CFStringCreateArrayBySeparatingStrings( NULL, py2app_CFSTR(ppath), py2app_CFSTR(":")); if (oldPath) { CFRange rng; rng.location = 0; rng.length = py2app_CFArrayGetCount(oldPath); py2app_CFArrayAppendArray(paths, oldPath, rng); py2app_CFRelease(oldPath); } } } optimize = py2app_CFDictionaryGetValue( options, py2app_CFSTR("optimize")); if (optimize) { int v = 0; char buf[32]; py2app_CFNumberGetValue(optimize, kCFNumberIntType, &v); snprintf(buf, 31, "%d", v); setenv("PYTHONOPTIMIZE", buf, 1); } } if (py2app_CFArrayGetCount(paths)) { resPath = py2app_CFStringCreateByCombiningStrings(NULL, paths, py2app_CFSTR(":")); setcfenv("PYTHONPATH", resPath); py2app_CFRelease(resPath); } else { if (getenv("PYTHONPATH") != NULL) { unsetenv("PYTHONPATH"); } } py2app_CFRelease(paths);}
开发者ID:asuc-octo,项目名称:tabulator,代码行数:81,
示例18: tryLoadOne/** * Try load VBoxXPCOMC.so/dylib/dll from the specified location and resolve all * the symbols we need. * * @returns 0 on success, -1 on failure and 1 if VBoxXPCOMC was not found. * @param dir The directory where to try load VBoxXPCOMC from. Can * be NULL. * @param setAppHome Whether to set the VBOX_APP_HOME env.var. or not. * @param ignoreMissing Whether to ignore missing library or not. * @param version Version number of the loaded API. */static inttryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing, unsigned int *version){ int result = -1; char *name = NULL; PFNVBOXGETXPCOMCFUNCTIONS pfnGetFunctions; if (dir != NULL) { if (virAsprintf(&name, "%s/%s", dir, DYNLIB_NAME) < 0) return -1; if (!virFileExists(name)) { if (!ignoreMissing) VIR_ERROR(_("Library '%s' doesn't exist"), name); VIR_FREE(name); return -1; } } else { if (VIR_STRDUP(name, DYNLIB_NAME) < 0) return -1; } /* * Try load it by that name, setting the VBOX_APP_HOME first (for now). * Then resolve and call the function table getter. */ if (setAppHome) { if (dir != NULL) { setenv("VBOX_APP_HOME", dir, 1 /* always override */); } else { unsetenv("VBOX_APP_HOME"); } } hVBoxXPCOMC = dlopen(name, RTLD_NOW | RTLD_LOCAL); if (hVBoxXPCOMC == NULL) { /* * FIXME: Don't warn in this case as it currently breaks make check * on systems without VirtualBox. */ if (dir != NULL) VIR_WARN("Could not dlopen '%s': %s", name, dlerror()); goto cleanup; } pfnGetFunctions = (PFNVBOXGETXPCOMCFUNCTIONS) dlsym(hVBoxXPCOMC, VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME); if (pfnGetFunctions == NULL) { VIR_ERROR(_("Could not dlsym %s from '%s': %s"), VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME, name, dlerror()); goto cleanup; } pVBoxFuncs_v2_2 = pfnGetFunctions(VBOX_XPCOMC_VERSION); if (pVBoxFuncs_v2_2 == NULL) { VIR_ERROR(_("Calling %s from '%s' failed"), VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME, name); goto cleanup; } *version = pVBoxFuncs_v2_2->pfnGetVersion(); g_pfnGetFunctions = pfnGetFunctions; result = 0; if (dir != NULL) { VIR_DEBUG("Found %s in '%s'", DYNLIB_NAME, dir); } else { VIR_DEBUG("Found %s in dynamic linker search path", DYNLIB_NAME); } cleanup: if (hVBoxXPCOMC != NULL && result < 0) { dlclose(hVBoxXPCOMC); hVBoxXPCOMC = NULL; } VIR_FREE(name); return result;}
开发者ID:libvirt,项目名称:libvirt,代码行数:97,
示例19: py2app_mainstatic int py2app_main(int argc, char * const *argv, char * const *envp) { CFArrayRef pyLocations; CFStringRef pyLocation; CFStringRef mainScript; CFStringRef pythonInterpreter; char *resource_path; char buf[PATH_MAX]; char c_pythonInterpreter[PATH_MAX]; char c_mainScript[PATH_MAX]; char **argv_new; struct stat sb; void *py_dylib; int rval; FILE *mainScriptFile; char* curenv = NULL; char* curlocale = NULL; if (getenv("PYTHONOPTIMIZE") != NULL) { unsetenv("PYTHONOPTIMIZE"); } if (getenv("PYTHONDEBUG") != NULL) { unsetenv("PYTHONDEBUG"); } if (getenv("PYTHONDONTWRITEBYTECODE") != NULL) { unsetenv("PYTHONDONTWRITEBYTECODE"); } if (getenv("PYTHONIOENCODING") != NULL) { unsetenv("PYTHONIOENCODING"); } if (getenv("PYTHONDUMPREFS") != NULL) { unsetenv("PYTHONDUMPREFS"); } if (getenv("PYTHONMALLOCSTATS") != NULL) { unsetenv("PYTHONMALLOCSTATS"); } /* Ensure that the interpreter won't try to write bytecode files * Two reasons: * - Apps are often read-only for users * - Writing byte-code will be blocked by the sandbox * when running a sandboxed application. */ setenv("PYTHONDONTWRITEBYTECODE", "1", 1);#ifndef PY2APP_SECONDARY /* * Force stdout/stderr to be unbuffered, needed when using the ASL * output redirection because Python 3's IO library won't use * line buffering with that. */ setenv("PYTHONUNBUFFERED", "1", 1);#endif if (!py2app_getApplicationName()) return report_error(ERR_NONAME); pyLocations = (CFArrayRef)py2app_getKey("PyRuntimeLocations"); if (!pyLocations) return report_error(ERR_PYRUNTIMELOCATIONS); pyLocation = py2app_findPyLocation(pyLocations); if (!pyLocation) return report_error(ERR_NOPYTHONRUNTIME); setExecutablePath(); setResourcePath(); /* check for ':' in path, not compatible with Python due to Py_GetPath */ /* XXX: Could work-around by creating something in /tmp I guess */ resource_path = getenv("RESOURCEPATH"); if ((resource_path == NULL) || (strchr(resource_path, ':') != NULL)) { return report_error(ERR_COLONPATH); } py2app_setPythonPath(); setenv("ARGVZERO", argv[0], 1); /* Clear unwanted environment variable that could be set * by a PyObjC bundle in a parent process. Not clearing causes * problems in PyObjC. */ if (getenv("PYOBJC_BUNDLE_ADDRESS") != NULL) { unsetenv("PYOBJC_BUNDLE_ADDRESS"); } snprintf(buf, sizeof(buf)-1, "PYOBJC_BUNDLE_ADDRESS%ld", (long)getpid()); if (getenv(buf) != NULL) { unsetenv(buf); } mainScript = getMainScript(); if (!mainScript) return report_error(ERR_NOPYTHONSCRIPT); pythonInterpreter = getPythonInterpreter(pyLocation); py2app_CFStringGetCString( pythonInterpreter, c_pythonInterpreter, sizeof(c_pythonInterpreter), kCFStringEncodingUTF8); py2app_CFRelease(pythonInterpreter); if (lstat(c_pythonInterpreter, &sb) == 0) { if (!((sb.st_mode & S_IFLNK) == S_IFLNK)) { setenv("PYTHONHOME", resource_path, 1); } } py2app_CFStringGetCString(pyLocation, buf, sizeof(buf), kCFStringEncodingUTF8); py_dylib = dlopen(buf, RTLD_LAZY);//.........这里部分代码省略.........
开发者ID:asuc-octo,项目名称:tabulator,代码行数:101,
示例20: cl_setenvint cl_setenv(const char *name, const char *value){ return (value == NULL) ? unsetenv(name) : setenv(name, value, 1);}
开发者ID:DonkeyWs,项目名称:libgit2,代码行数:4,
示例21: execunsetenvvoid execunsetenv(Cmd c, int inPipeId, int outPipeId){ int newfd; int i=0; char* str; if(c->next == NULL) { //if(fork() == 0) // { redirection(c, inPipeId, outPipeId); if(c->args[1] == NULL) { perror("Variable not input"); } else{ //printf("TP"); //printf("Invoking Putenv for %s to null",c->args[1]); str = strdup(c->args[1]); unsetenv(str); } // exit(0); //} //else //{ // wait(); //} } else { if(fork() == 0) { redirection(c, inPipeId, outPipeId); if(c->args[1] == NULL) { perror("Variable not input"); } else{ //printf("TP"); //printf("Invoking Putenv for %s to null",c->args[1]); str = strdup(c->args[1]); unsetenv(str); } exit(0); } else { close((pipes+(2*outPipeId))[1]); wait(); } }}
开发者ID:priyaranjan-behera,项目名称:OSPrograms,代码行数:66,
示例22: command_bootstatic intcommand_boot(int argc, char *argv[]){ struct preloaded_file *fp; char *local_module_path; char *exported_module_path; /* * See if the user has specified an explicit kernel to boot. */ if ((argc > 1) && (argv[1][0] != '-')) { /* XXX maybe we should discard everything and start again? */ if (file_findfile(NULL, NULL) != NULL) { sprintf(command_errbuf, "can't boot '%s', kernel module already loaded", argv[1]); return(CMD_ERROR); } /* find/load the kernel module */ if (mod_loadkld(argv[1], argc - 2, argv + 2) != 0) return(CMD_ERROR); /* we have consumed all arguments */ argc = 1; } /* * See if there is a kernel module already loaded */ if (file_findfile(NULL, NULL) == NULL) if (loadakernel(0, argc - 1, argv + 1)) /* we have consumed all arguments */ argc = 1; /* * Loaded anything yet? */ if ((fp = file_findfile(NULL, NULL)) == NULL) { command_errmsg = "no bootable kernel"; return(CMD_ERROR); } /* * If we were given arguments, discard any previous. * XXX should we merge arguments? Hard to DWIM. */ if (argc > 1) { if (fp->f_args != NULL) free(fp->f_args); fp->f_args = unargv(argc - 1, argv + 1); } /* Hook for platform-specific autoloading of modules */ if (archsw.arch_autoload() != 0) return(CMD_ERROR); /* * Exec the kernel. We have to shift our exported_module_path * (which has the correct /boot prefix for the kernel) over to * module_path. If the exec fails we switch it back. */ exported_module_path = getenv("exported_module_path"); if (exported_module_path) { exported_module_path = strdup(exported_module_path); local_module_path = getenv("module_path"); if (local_module_path) local_module_path = strdup(local_module_path); setenv("module_path", exported_module_path, 1); unsetenv("exported_module_path"); } /* Call the exec handler from the loader matching the kernel */ file_formats[fp->f_loader]->l_exec(fp); if (exported_module_path) { if (local_module_path) { setenv("module_path", local_module_path, 1); free(local_module_path); } else { unsetenv("module_path"); } setenv("exported_module_path", exported_module_path, 1); free(exported_module_path); } return(CMD_ERROR);}
开发者ID:zrj-rimwis,项目名称:blub,代码行数:85,
示例23: launch_client_initvoidlaunch_client_init(void){ struct sockaddr_un sun; char *where = getenv(LAUNCHD_SOCKET_ENV); char *_launchd_fd = getenv(LAUNCHD_TRUSTED_FD_ENV); int dfd, lfd = -1, cifd = -1;#ifdef __APPLE__ name_t spath;#else#warning "PORT: Figure out how to handle this path from bootstrap void *spath;#endif if (_launchd_fd) { cifd = strtol(_launchd_fd, NULL, 10); if ((dfd = dup(cifd)) >= 0) { close(dfd); _fd(cifd); } else { cifd = -1; } unsetenv(LAUNCHD_TRUSTED_FD_ENV); } memset(&sun, 0, sizeof(sun)); sun.sun_family = AF_UNIX; /* The rules are as follows. * - All users (including root) talk to their per-user launchd's by default. * - If we have been invoked under sudo, talk to the system launchd. * - If we're the root user and the __USE_SYSTEM_LAUNCHD environment variable is set, then * talk to the system launchd. */ if (where && where[0] != '/0') { strncpy(sun.sun_path, where, sizeof(sun.sun_path)); } else { if (_vprocmgr_getsocket(spath) == 0) { if ((getenv("SUDO_COMMAND") || getenv("__USE_SYSTEM_LAUNCHD")) && geteuid() == 0) { /* Talk to the system launchd. */ strncpy(sun.sun_path, LAUNCHD_SOCK_PREFIX "/sock", sizeof(sun.sun_path)); } else { /* Talk to our per-user launchd. */ size_t min_len; min_len = sizeof(sun.sun_path) < sizeof(spath) ? sizeof(sun.sun_path) : sizeof(spath); strncpy(sun.sun_path, spath, min_len); } } } launch_globals_t globals = _launch_globals(); if ((lfd = _fd(socket(AF_UNIX, SOCK_STREAM, 0))) == -1) { goto out_bad; }#if TARGET_OS_EMBEDDED (void)vproc_swap_integer(NULL, VPROC_GSK_EMBEDDEDROOTEQUIVALENT, NULL, &globals->s_am_embedded_god);#endif if (-1 == connect(lfd, (struct sockaddr *)&sun, sizeof(sun))) { if (cifd != -1 || globals->s_am_embedded_god) { /* There is NO security enforced by this check. This is just a hint to our * library that we shouldn't error out due to failing to open this socket. If * we inherited a trusted file descriptor, we shouldn't fail. This should be * adequate for clients' expectations. */ close(lfd); lfd = -1; } else { goto out_bad; } } if (!(globals->l = launchd_fdopen(lfd, cifd))) { goto out_bad; } if (!(globals->async_resp = launch_data_alloc(LAUNCH_DATA_ARRAY))) { goto out_bad; } return;out_bad: if (globals->l) { launchd_close(globals->l, close); globals->l = NULL; } else if (lfd != -1) { close(lfd); } if (cifd != -1) { close(cifd); }}
开发者ID:CameronNemo,项目名称:openlaunchd,代码行数:94,
示例24: test_str_screen_wrapvoidtest_str_screen_wrap (void){ char *str = NULL; struct winsize winsize; int pty, pts; TEST_FUNCTION ("nih_str_screen_wrap"); unsetenv ("COLUMNS"); winsize.ws_row = 24; winsize.ws_col = 40; winsize.ws_xpixel = 0; winsize.ws_ypixel = 0; openpty (&pty, &pts, NULL, NULL, &winsize); /* Check that we correctly wrap text to the width of the screen * when it is available. */ TEST_FEATURE ("with screen width"); TEST_ALLOC_FAIL { TEST_DIVERT_STDOUT_FD (pts) { str = nih_str_screen_wrap ( NULL, ("this is a string that " "should need wrapping at " "any different screen width " "that we choose to set"), 0, 0); } if (test_alloc_failed) { TEST_EQ_P (str, NULL); continue; } TEST_EQ_STR (str, ("this is a string that should need/n" "wrapping at any different screen width/n" "that we choose to set")); nih_free (str); } /* Check that we wrap at the number specified in the COLUMNS * variable in preference to the width of the screen. */ TEST_FEATURE ("with COLUMNS variable"); putenv ("COLUMNS=30"); TEST_ALLOC_FAIL { TEST_DIVERT_STDOUT_FD (pts) { str = nih_str_screen_wrap ( NULL, ("this is a string that " "should need wrapping at " "any different screen width " "that we choose to set"), 0, 0); } if (test_alloc_failed) { TEST_EQ_P (str, NULL); continue; } TEST_EQ_STR (str, ("this is a string that should/n" "need wrapping at any/n" "different screen width that/n" "we choose to set")); nih_free (str); } unsetenv ("COLUMNS"); close (pts); close (pty); /* Check that we fallback to assuming 80 columns if we don't have * any luck with either the tty or COLUMNS variable. */ TEST_FEATURE ("with fallback to 80 columns"); pts = open ("/dev/null", O_RDWR | O_NOCTTY); TEST_ALLOC_FAIL { TEST_DIVERT_STDOUT_FD (pts) { str = nih_str_screen_wrap ( NULL, ("this is a string that " "should need wrapping at " "any different screen width " "that we choose to set"), 0, 0); } if (test_alloc_failed) { TEST_EQ_P (str, NULL); continue; } TEST_EQ_STR (str, ("this is a string that should need " "wrapping at any different screen width " "that/n"//.........这里部分代码省略.........
开发者ID:cmjonze,项目名称:libnih,代码行数:101,
示例25: mainint main(int argc, char **argv){ char buf[MAXLEN]; char line[83]; int i, f, ch; int len = 0; int remote = 0; char *p; char *whoami; struct passwd *pwd; buf[0] = 0; if ((pwd = getpwuid(getuid())) == NULL) { if (getuid() == 0) whoami = "root"; else { fprintf(stderr, "You don't exist. Go away./n"); exit(1); } } else whoami = pwd->pw_name; while((ch = getopt(argc, argv, "n")) != EOF) switch(ch) { case 'n': /* * Undocumented option for suppressing * banner from rpc.rwalld. Only works if * we are root or if we're NOT setgid. */ if (geteuid() != 0 && getgid() != getegid()) { fprintf(stderr, "wall -n: not priviliged/n"); exit(1); } remote = 1; break; default: fprintf(stderr, "usage: wall [message]/n"); return 1; break; } if ((argc - optind) > 0) { for(f = optind; f < argc; f++) { len += strlen(argv[f]) + 1; if (len >= MAXLEN-2) break; strcat(buf, argv[f]); if (f < argc-1) strcat(buf, " "); } strcat(buf, "/r/n"); } else { while(fgets(line, 80, stdin)) { /* * Make sure that line ends in /r/n */ for(p = line; *p && *p != '/r' && *p != '/n'; p++) ; strcpy(p, "/r/n"); len += strlen(line); if (len >= MAXLEN) break; strcat(buf, line); } } i = 0; for (p = buf; *p; p++) { if (*p == '/n' && ++i >= MAXLINES) { *++p = 0; break; } } openlog("wall", LOG_PID, LOG_USER); syslog(LOG_INFO, "wall: user %s broadcasted %d lines (%zu chars)", whoami, i, strlen(buf)); closelog(); unsetenv("TZ"); wall(buf, remote); /*NOTREACHED*/ return 0;}
开发者ID:mikess,项目名称:sysvinit,代码行数:83,
示例26: NS_ASSERTIONNS_IMETHODIMPnsNativeAppSupportUnix::Start(bool *aRetVal){ NS_ASSERTION(gAppData, "gAppData must not be null.");// The dbus library is used by both nsWifiScannerDBus and BluetoothDBusService,// from diffrent threads. This could lead to race conditions if the dbus is not// initialized before making any other library calls.#ifdef MOZ_ENABLE_DBUS dbus_threads_init_default();#endif#if (MOZ_WIDGET_GTK == 2) if (gtk_major_version < MIN_GTK_MAJOR_VERSION || (gtk_major_version == MIN_GTK_MAJOR_VERSION && gtk_minor_version < MIN_GTK_MINOR_VERSION)) { GtkWidget* versionErrDialog = gtk_message_dialog_new(nullptr, GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, UNSUPPORTED_GTK_MSG, gtk_major_version, gtk_minor_version, MIN_GTK_MAJOR_VERSION, MIN_GTK_MINOR_VERSION); gtk_dialog_run(GTK_DIALOG(versionErrDialog)); gtk_widget_destroy(versionErrDialog); exit(0); }#endif *aRetVal = true;#ifdef MOZ_X11 gboolean sm_disable = FALSE; if (!getenv("SESSION_MANAGER")) { sm_disable = TRUE; } nsAutoCString prev_client_id; char **curarg = gArgv + 1; while (*curarg) { char *arg = *curarg; if (arg[0] == '-' && arg[1] == '-') { arg += 2; if (!strcmp(arg, "sm-disable")) { RemoveArg(curarg); sm_disable = TRUE; continue; } else if (!strcmp(arg, "sm-client-id")) { RemoveArg(curarg); if (*curarg[0] != '-') { prev_client_id = *curarg; RemoveArg(curarg); } continue; } } ++curarg; } if (prev_client_id.IsEmpty()) { prev_client_id = getenv("DESKTOP_AUTOSTART_ID"); } // We don't want child processes to use the same ID unsetenv("DESKTOP_AUTOSTART_ID"); char *client_id = nullptr; if (!sm_disable) { PRLibrary *iceLib = PR_LoadLibrary("libICE.so.6"); if (!iceLib) { return NS_OK; } PRLibrary *smLib = PR_LoadLibrary("libSM.so.6"); if (!smLib) { PR_UnloadLibrary(iceLib); return NS_OK; } IceSetIOErrorHandler = (IceSetIOErrorHandlerFn)PR_FindFunctionSymbol(iceLib, "IceSetIOErrorHandler"); IceAddConnectionWatch = (IceAddConnectionWatchFn)PR_FindFunctionSymbol(iceLib, "IceAddConnectionWatch"); IceConnectionNumber = (IceConnectionNumberFn)PR_FindFunctionSymbol(iceLib, "IceConnectionNumber"); IceProcessMessages = (IceProcessMessagesFn)PR_FindFunctionSymbol(iceLib, "IceProcessMessages"); IceGetConnectionContext = (IceGetConnectionContextFn)PR_FindFunctionSymbol(iceLib, "IceGetConnectionContext"); if (!IceSetIOErrorHandler || !IceAddConnectionWatch || !IceConnectionNumber || !IceProcessMessages || !IceGetConnectionContext) { PR_UnloadLibrary(iceLib); PR_UnloadLibrary(smLib); return NS_OK; } SmcInteractDone = (SmcInteractDoneFn)PR_FindFunctionSymbol(smLib, "SmcInteractDone"); SmcSaveYourselfDone = (SmcSaveYourselfDoneFn)PR_FindFunctionSymbol(smLib, "SmcSaveYourselfDone"); SmcInteractRequest = (SmcInteractRequestFn)PR_FindFunctionSymbol(smLib, "SmcInteractRequest"); SmcCloseConnection = (SmcCloseConnectionFn)PR_FindFunctionSymbol(smLib, "SmcCloseConnection"); SmcOpenConnection = (SmcOpenConnectionFn)PR_FindFunctionSymbol(smLib, "SmcOpenConnection");//.........这里部分代码省略.........
开发者ID:brendandahl,项目名称:positron,代码行数:101,
示例27: mainintmain(int argc, char ** argv){ const char * line; unsigned i; if (argc > 1) { test_program_arg = argv[1]; sxe_log_hook_line_out(test_log_line_out_to_stdout); SXEA10(sxe_log_hook_line_out(test_log_line_out_to_stdout) == test_log_line_out_to_stdout, "sxe_log_hook_line_out failed to hook test_log_line_out_to_stdout"); if (strcmp(argv[1], "1") == 0) { if (getenv("SXE_LOG_LEVEL") != NULL) { SXED80("should not see this (level too high)", strlen("should not see this (level too high)")); /* Cover early out in dump */ } SXEL40("BOO"); } else if (strcmp(argv[1], "2") == 0) {#ifndef LOCAL_SXE_DEBUG sxe_log_set_indent_maximum(~0U);#endif sxe_log_set_level(SXE_LOG_LEVEL_WARNING); SXEE50("level_five()"); test_level_six(SXE_LOG_LEVEL_LIBRARY_DUMP); SXER50("return // five"); SXEE50("level_five()"); test_level_six(SXE_LOG_LEVEL_WARNING); SXER50("return // five"); SXEL20("that's all, folks"); } exit(0); } test_program_name = argv[0]; plan_tests(3 * TEST_LINES_EXPECTED + 3); /* Tests for different log level settings */ tap_test_case_name("Level settings"); ok((line = test_log_first("1")) != NULL, "Test log at default level wrote a line"); diag("line = %s", line); SXEA12(putenv((char *)(intptr_t)"SXE_LOG_LEVEL=2") >= 0, "%s: Failed to putenv: %s", test_program_name, strerror(errno)); ok(test_log_first("1") == NULL, "Test log with SXE_LOG_LEVEL=2 failed to write a line"); /* TODO: Replace putenvs with calls to the TBD function that allows setting fine grained levels programmatically. */ SXEA12(putenv((char *)(intptr_t)"SXE_LOG_LEVEL_LIBSXE=5") >= 0, "%s: Failed to putenv: %s", test_program_name, strerror(errno)); ok((line = test_log_first("1")) != NULL, "Test log with SXE_LOG_LEVEL_LIBSXE=5 wrote a line"); diag("line = %s", line); SXEA12(putenv((char *)(intptr_t)"SXE_LOG_LEVEL_LIBSXE_LIB_SXE_LOG=2") >= 0, "%s: Failed to setenv: %s", test_program_name, strerror(errno)); ok(test_log_first("1") == NULL, "Test log with SXE_LOG_LEVEL_LIBSXE_LIB_SXE_LOG=2 failed to write a line"); SXEA12(putenv((char *)(intptr_t)"SXE_LOG_LEVEL_LIBSXE_LIB_SXE_LOG_TEST_TEST_SXE_LOG_LEVELS=7") >= 0, "%s: Failed to putenv: %s", test_program_name, strerror(errno)); ok((line = test_log_first("1")) != NULL, "Test log with SXE_LOG_LEVEL_LIBSXE_LIB_SXE_LOG_TEST_TEST_SXE_LOG_LEVELS=7 wrote a line"); diag("line = %s", line); /* Remove the more specific environment variables */ SXEA12(unsetenv("SXE_LOG_LEVEL_LIBSXE") == 0, "%s: unsetenv failed: %s", test_program_name, strerror(errno)); SXEA12(unsetenv("SXE_LOG_LEVEL_LIBSXE_LIB_SXE_LOG") == 0, "%s: unsetenv failed: %s", test_program_name, strerror(errno)); SXEA12(unsetenv("SXE_LOG_LEVEL_LIBSXE_LIB_SXE_LOG_TEST_TEST_SXE_LOG_LEVELS") == 0, "%s: unsetenv failed: %s", test_program_name, strerror(errno)); /* Tests for indentation interacting with log level */ tap_test_case_name("Indentation"); line = test_log_first("2"); for (i = 0; i < TEST_LINES_EXPECTED; i++) { ok(line != NULL, "Got line %u", 2 * i + 1); ok(strstr(line, test_expected[i]) != NULL, "Found '%s' in '%.*s'", test_expected[i], (int)strlen(line) - 1, line); if (i > 2) { ok(test_log_next() != NULL, "Got line %u", 2 * i + 2); } line = test_log_next(); } ok(line == NULL, "Got EOF"); return exit_status();}
开发者ID:davidu,项目名称:sxe,代码行数:84,
示例28: unset_envint unset_env(char *name) { return unsetenv(name);}
开发者ID:kevinqmcdonald,项目名称:shellproject,代码行数:3,
注:本文中的unsetenv函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ unshare_fd函数代码示例 C++ unsetPendingActivity函数代码示例 |