MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsdStartProcess

Function cupsdStartProcess

scheduler/process.c:460–847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458 */
459
460int /* O - Process ID or 0 */
461cupsdStartProcess(
462 const char *command, /* I - Full path to command */
463 char *argv[], /* I - Command-line arguments */
464 char *envp[], /* I - Environment */
465 int infd, /* I - Standard input file descriptor */
466 int outfd, /* I - Standard output file descriptor */
467 int errfd, /* I - Standard error file descriptor */
468 int backfd, /* I - Backchannel file descriptor */
469 int sidefd, /* I - Sidechannel file descriptor */
470 int root, /* I - Run as root? */
471 void *profile, /* I - Security profile to use */
472 cupsd_job_t *job, /* I - Job associated with process */
473 int *pid) /* O - Process ID */
474{
475 int i; /* Looping var */
476 const char *exec_path = command; /* Command to be exec'd */
477 char *real_argv[110], /* Real command-line arguments */
478 cups_exec[1024], /* Path to "cups-exec" program */
479 user_str[16], /* User string */
480 group_str[16], /* Group string */
481 nice_str[16]; /* FilterNice string */
482 uid_t user; /* Command UID */
483 cupsd_proc_t *proc; /* New process record */
484#if USE_POSIX_SPAWN
485 posix_spawn_file_actions_t actions; /* Spawn file actions */
486 posix_spawnattr_t attrs; /* Spawn attributes */
487 sigset_t defsignals; /* Default signals */
488#elif defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
489 struct sigaction action; /* POSIX signal handler */
490#endif /* USE_POSIX_SPAWN */
491#if defined(__APPLE__)
492 char processPath[1024], /* CFProcessPath environment variable */
493 linkpath[1024]; /* Link path for symlinks... */
494 int linkbytes; /* Bytes for link path */
495#endif /* __APPLE__ */
496
497
498 *pid = 0;
499
500 /*
501 * Figure out the UID for the child process...
502 */
503
504 if (RunUser)
505 user = RunUser;
506 else if (root)
507 user = 0;
508 else
509 user = User;
510
511 /*
512 * Check the permissions of the command we are running...
513 */
514
515 if (_cupsFileCheck(command, _CUPS_FILE_CHECK_PROGRAM, !RunUser,
516 cupsdLogFCMessage, job ? job->printer : NULL))
517 return (0);

Callers 4

cupsd_start_notifierFunction · 0.85
pipe_commandFunction · 0.85
copy_modelFunction · 0.85
cupsdContinueJobFunction · 0.85

Calls 8

_cupsFileCheckFunction · 0.85
cupsdLogMessageFunction · 0.85
cupsdHoldSignalsFunction · 0.85
cupsdReleaseSignalsFunction · 0.85
cupsArrayNewFunction · 0.85
_cups_strcpyFunction · 0.85
cupsArrayAddFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected