add: if ((user != NULL) && (p = getpwnam(user)) != NULL) { syslog(LOG_DEBUG, "cascade_submit_job: user = %s\n", user); userid = p->pw_uid; syslog(LOG_DEBUG, "cascade_submit_job: userid = %d\n", userid); }  if (userid > 0) for (i = 0; df_list[i] != NULL; i++) { syslog(LOG_DEBUG, "cascade_submit_job: dffile = %s\n", df_list[i]); if ((chown(df_list[i], userid, -1)) < 0) syslog(LOG_DEBUG, "cascade_submit_job: chown failed"); else syslog(LOG_DEBUG, "cascade_submit_job: chown succeeded"); }
context: cascade_submit_job(const char *printer, const char *host, char *cf,		    char **df_list){	FILE *fp;	char *s, *newcf;	syslog(LOG_DEBUG, "cascade_submit_job(%s, %s, 0x%x, 0x%x)",		(printer ? printer : "NULL"), (host ? host : "NULL"), cf,		df_list);	/*	 * Validate/Cleanup the control/metadata file.	 */	if ((newcf = calloc(1, strlen(cf) + 1)) == NULL)		return (-1);	for (s = strtok(cf, "\n"); s != NULL; s = strtok(NULL, "\n")) {		/*		 * If the first character is 'U' then make sure that the		 * filename does not contain '/'		 */		if ((s[0] == CF_UNLINK) && (strchr(s, '/') != NULL)) {			syslog(LOG_ALERT, "suspicious directive: %s", s);		} else {			strcat(newcf, s);			strcat(newcf, "\n");		}	}	/* write the control file */	df_list[0][0] = 'c';	/*	 * Applying lock when bsd-gw is writing control file	 * in /var/spool/print directory	 */	if (((fp = fopen(df_list[0], "w")) != NULL) &&		((lockf(fileno(fp), F_LOCK, 0)) == 0)) {		fprintf(fp, "%s", newcf);		free(newcf);		fclose(fp);	} else {		free(newcf);		return (-1);	}	/* write a binding file */	df_list[0][0] = 'x';	/*	 * Applying lock when bsd-gw is writing xfile	 * in /var/spool/print directory	 */	if (((fp = fopen(df_list[0], "w")) != NULL) &&		((lockf(fileno(fp), F_LOCK, 0)) == 0)) {		fprintf(fp, "%s:%s\n", printer_addr->server,			printer_addr->printer);		fclose(fp);	} else {		df_list[0][0] = 'c';		unlink(df_list[0]);		return (-1);	}	start_daemon(1);	return (0);}