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

Function cupsdCreateProfile

scheduler/process.c:72–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 */
71
72void * /* O - Profile or NULL on error */
73cupsdCreateProfile(int job_id, /* I - Job ID or 0 for none */
74 int allow_networking)/* I - Allow networking off machine? */
75{
76#ifdef HAVE_SANDBOX_H
77 cups_file_t *fp; /* File pointer */
78 char profile[1024], /* File containing the profile */
79 bin[1024], /* Quoted ServerBin */
80 cache[1024], /* Quoted CacheDir */
81 domain[1024], /* Domain socket, if any */
82 request[1024], /* Quoted RequestRoot */
83 root[1024], /* Quoted ServerRoot */
84 state[1024], /* Quoted StateDir */
85 temp[1024]; /* Quoted TempDir */
86 const char *nodebug; /* " (with no-log)" for no debug */
87 cupsd_listener_t *lis; /* Current listening socket */
88
89
90 if (!UseSandboxing || Sandboxing == CUPSD_SANDBOXING_OFF)
91 {
92 /*
93 * Only use sandbox profiles as root...
94 */
95
96 cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCreateProfile(job_id=%d, allow_networking=%d) = NULL", job_id, allow_networking);
97
98 return (NULL);
99 }
100
101 if ((fp = cupsTempFile2(profile, sizeof(profile))) == NULL)
102 {
103 /*
104 * This should never happen, and is fatal when sandboxing is enabled.
105 */
106
107 cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCreateProfile(job_id=%d, allow_networking=%d) = NULL", job_id, allow_networking);
108 cupsdLogMessage(CUPSD_LOG_EMERG, "Unable to create security profile: %s", strerror(errno));
109 kill(getpid(), SIGTERM);
110 return (NULL);
111 }
112
113 fchown(cupsFileNumber(fp), RunUser, Group);
114 fchmod(cupsFileNumber(fp), 0640);
115
116 cupsd_requote(bin, ServerBin, sizeof(bin));
117 cupsd_requote(cache, CacheDir, sizeof(cache));
118 cupsd_requote(request, RequestRoot, sizeof(request));
119 cupsd_requote(root, ServerRoot, sizeof(root));
120 cupsd_requote(state, StateDir, sizeof(state));
121 cupsd_requote(temp, TempDir, sizeof(temp));
122
123 nodebug = LogLevel < CUPSD_LOG_DEBUG ? " (with no-log)" : "";
124
125 cupsFilePuts(fp, "(version 1)\n");
126 if (Sandboxing == CUPSD_SANDBOXING_STRICT)
127 cupsFilePuts(fp, "(deny default)\n");
128 else
129 cupsFilePuts(fp, "(allow default)\n");

Callers 3

cupsdStartServerFunction · 0.85
start_jobFunction · 0.85
mainFunction · 0.85

Calls 11

cupsdLogMessageFunction · 0.85
cupsTempFile2Function · 0.85
cupsFileNumberFunction · 0.85
cupsd_requoteFunction · 0.85
cupsFilePutsFunction · 0.85
cupsFilePrintfFunction · 0.85
cupsArrayFirstFunction · 0.85
cupsArrayNextFunction · 0.85
httpAddrFamilyFunction · 0.85
httpAddrStringFunction · 0.85
cupsFileCloseFunction · 0.85

Tested by

no test coverage detected