mirror of
https://github.com/samba-team/samba.git
synced 2025-02-24 13:57:43 +03:00
Removed mktemp from HEAD - same as done in 2.2.
Jeremy.
This commit is contained in:
parent
89589895e3
commit
121b59669f
@ -319,6 +319,27 @@ int sys_acl_set_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
|
||||
int sys_acl_free_text(char *text);
|
||||
int sys_acl_free_acl(SMB_ACL_T the_acl) ;
|
||||
int sys_acl_free_qualifier(void *qual) ;
|
||||
int sys_acl_get_entry( SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
|
||||
int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
|
||||
int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
|
||||
void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d);
|
||||
SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type);
|
||||
SMB_ACL_T sys_acl_get_fd(int fd);
|
||||
int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset);
|
||||
int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
|
||||
char *sys_acl_to_text( SMB_ACL_T theacl, ssize_t *plen);
|
||||
SMB_ACL_T sys_acl_init( int count);
|
||||
int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
|
||||
int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
|
||||
int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual);
|
||||
int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset);
|
||||
int sys_acl_valid( SMB_ACL_T theacl );
|
||||
int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
|
||||
int sys_acl_set_fd( int fd, SMB_ACL_T theacl);
|
||||
int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm);
|
||||
int sys_acl_free_text(char *text);
|
||||
int sys_acl_free_acl(SMB_ACL_T posix_acl);
|
||||
int sys_acl_free_qualifier(void *qual);
|
||||
int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
|
||||
int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
|
||||
int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
|
||||
@ -494,7 +515,6 @@ int str_checksum(const char *s);
|
||||
void zero_free(void *p, size_t size);
|
||||
int set_maxfiles(int requested_max);
|
||||
BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name);
|
||||
char *smbd_mktemp(char *template);
|
||||
int smb_mkstemp(char *template);
|
||||
void *memdup(void *p, size_t size);
|
||||
char *myhostname(void);
|
||||
@ -2102,7 +2122,7 @@ int sysv_printername_ok(char *name);
|
||||
|
||||
/*The following definitions come from printing/printfsp.c */
|
||||
|
||||
files_struct *print_fsp_open(connection_struct *conn,char *jobname);
|
||||
files_struct *print_fsp_open(connection_struct *conn);
|
||||
void print_fsp_end(files_struct *fsp, BOOL normal_close);
|
||||
|
||||
/*The following definitions come from printing/printing.c */
|
||||
|
@ -881,23 +881,17 @@ char *automount_lookup(char *user_name)
|
||||
|
||||
char *nis_map = (char *)lp_nis_home_map_name();
|
||||
|
||||
char nis_domain[NIS_MAXNAMELEN + 1];
|
||||
char buffer[NIS_MAXATTRVAL + 1];
|
||||
nis_result *result;
|
||||
nis_object *object;
|
||||
entry_obj *entry;
|
||||
|
||||
strncpy(nis_domain, (char *)nis_local_directory(), NIS_MAXNAMELEN);
|
||||
nis_domain[NIS_MAXNAMELEN] = '\0';
|
||||
|
||||
DEBUG(5, ("NIS+ Domain: %s\n", nis_domain));
|
||||
|
||||
if (strcmp(user_name, last_key))
|
||||
{
|
||||
slprintf(buffer, sizeof(buffer)-1, "[%s=%s]%s.%s", "key", user_name, nis_map, nis_domain);
|
||||
slprintf(buffer, sizeof(buffer)-1, "[key=%s],%s", user_name, nis_map);
|
||||
DEBUG(5, ("NIS+ querystring: %s\n", buffer));
|
||||
|
||||
if (result = nis_list(buffer, RETURN_RESULT, NULL, NULL))
|
||||
if (result = nis_list(buffer, FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP, NULL, NULL))
|
||||
{
|
||||
if (result->status != NIS_SUCCESS)
|
||||
{
|
||||
@ -1738,34 +1732,6 @@ BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name)
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
like mktemp() but make sure that no % characters are used
|
||||
% characters are bad for us because of the macro subs
|
||||
*****************************************************************/
|
||||
char *smbd_mktemp(char *template)
|
||||
{
|
||||
char *p = mktemp(template);
|
||||
char *p2;
|
||||
SMB_STRUCT_STAT st;
|
||||
|
||||
if (!p) return NULL;
|
||||
|
||||
while ((p2=strchr(p,'%'))) {
|
||||
p2[0] = 'A';
|
||||
while (sys_stat(p,&st) == 0 && p2[0] < 'Z') {
|
||||
/* damn, it exists */
|
||||
p2[0]++;
|
||||
}
|
||||
if (p2[0] == 'Z') {
|
||||
/* oh well ... better return something */
|
||||
p2[0] = '%';
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
possibly replace mkstemp if it is broken
|
||||
*****************************************************************/
|
||||
@ -1775,8 +1741,8 @@ int smb_mkstemp(char *template)
|
||||
return mkstemp(template);
|
||||
#else
|
||||
/* have a reasonable go at emulating it. Hope that
|
||||
the system mktemp() isn't completly hopeless */
|
||||
char *p = smbd_mktemp(template);
|
||||
the system mktemp() isn't completly hopeless */
|
||||
char *p = mktemp(template);
|
||||
if (!p) return -1;
|
||||
return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
|
||||
#endif
|
||||
@ -1876,7 +1842,6 @@ BOOL ms_has_wild(char *s)
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
a wrapper that handles case sensitivity and the special handling
|
||||
of the ".." name
|
||||
|
@ -29,7 +29,7 @@ open a print file and setup a fsp for it. This is a wrapper around
|
||||
print_job_start().
|
||||
***************************************************************************/
|
||||
|
||||
files_struct *print_fsp_open(connection_struct *conn,char *jobname)
|
||||
files_struct *print_fsp_open(connection_struct *conn)
|
||||
{
|
||||
int jobid;
|
||||
SMB_STRUCT_STAT sbuf;
|
||||
@ -39,7 +39,7 @@ files_struct *print_fsp_open(connection_struct *conn,char *jobname)
|
||||
if(!fsp)
|
||||
return NULL;
|
||||
|
||||
jobid = print_job_start(¤t_user, SNUM(conn), jobname);
|
||||
jobid = print_job_start(¤t_user, SNUM(conn), "smb.prn");
|
||||
if (jobid == -1) {
|
||||
file_free(fsp);
|
||||
return NULL;
|
||||
|
@ -386,7 +386,7 @@ static void print_queue_update(int snum)
|
||||
/* get the current queue using the appropriate interface */
|
||||
ZERO_STRUCT(status);
|
||||
|
||||
qcount = (*(current_printif->queue_get))(snum, &queue, &status);
|
||||
qcount = (*(current_printif->queue_get))(snum, &queue, &status);
|
||||
|
||||
DEBUG(3, ("%d job%s in queue for %s\n", qcount, (qcount != 1) ?
|
||||
"s" : "", printer_name));
|
||||
@ -575,7 +575,7 @@ static BOOL print_job_delete1(int jobid)
|
||||
print_job_store(jobid, pjob);
|
||||
|
||||
if (pjob->spooled && pjob->sysjob != -1)
|
||||
result = (*(current_printif->job_delete))(snum, pjob);
|
||||
result = (*(current_printif->job_delete))(snum, pjob);
|
||||
|
||||
/* Delete the tdb entry if the delete suceeded or the job hasn't
|
||||
been spooled. */
|
||||
@ -667,7 +667,7 @@ BOOL print_job_pause(struct current_user *user, int jobid, int *errcode)
|
||||
}
|
||||
|
||||
/* need to pause the spooled entry */
|
||||
ret = (*(current_printif->job_pause))(snum, pjob);
|
||||
ret = (*(current_printif->job_pause))(snum, pjob);
|
||||
|
||||
if (ret != 0) {
|
||||
*errcode = ERROR_INVALID_PARAMETER;
|
||||
@ -892,7 +892,6 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
|
||||
/* lock the database */
|
||||
tdb_lock_bystring(tdb, "INFO/nextjob");
|
||||
|
||||
next_jobnum:
|
||||
next_jobid = tdb_fetch_int(tdb, "INFO/nextjob");
|
||||
if (next_jobid == -1) next_jobid = 1;
|
||||
|
||||
@ -906,18 +905,10 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
|
||||
|
||||
tdb_store_int(tdb, "INFO/nextjob", jobid);
|
||||
|
||||
/* we have a job entry - now create the spool file
|
||||
|
||||
we unlink first to cope with old spool files and also to beat
|
||||
a symlink security hole - it allows us to use O_EXCL
|
||||
There may be old spool files owned by other users lying around.
|
||||
*/
|
||||
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%d",
|
||||
path, PRINT_SPOOL_PREFIX, jobid);
|
||||
if (unlink(pjob.filename) == -1 && errno != ENOENT) {
|
||||
goto next_jobnum;
|
||||
}
|
||||
pjob.fd = sys_open(pjob.filename,O_WRONLY|O_CREAT|O_EXCL,0600);
|
||||
/* we have a job entry - now create the spool file */
|
||||
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%sXXXXXX",
|
||||
path, PRINT_SPOOL_PREFIX);
|
||||
pjob.fd = smb_mkstemp(pjob.filename);
|
||||
|
||||
if (pjob.fd == -1) {
|
||||
if (errno == EACCES) {
|
||||
|
@ -600,7 +600,7 @@ files_struct *open_file_shared(connection_struct *conn,char *fname, SMB_STRUCT_S
|
||||
ignored */
|
||||
*Access = DOS_OPEN_WRONLY;
|
||||
*action = FILE_WAS_CREATED;
|
||||
return print_fsp_open(conn, fname);
|
||||
return print_fsp_open(conn);
|
||||
}
|
||||
|
||||
fsp = file_new(conn);
|
||||
|
@ -1835,6 +1835,7 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
||||
BOOL bad_path = False;
|
||||
files_struct *fsp;
|
||||
int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
|
||||
int tmpfd;
|
||||
SMB_STRUCT_STAT sbuf;
|
||||
char *p;
|
||||
|
||||
@ -1850,15 +1851,23 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
||||
|
||||
unixmode = unix_mode(conn,createmode,fname);
|
||||
|
||||
pstrcpy(fname2,(char *)smbd_mktemp(fname));
|
||||
/* This file should not exist. */
|
||||
ZERO_STRUCT(sbuf);
|
||||
tmpfd = smb_mkstemp(fname);
|
||||
if (tmpfd == -1) {
|
||||
END_PROFILE(SMBctemp);
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
|
||||
vfs_stat(conn,fname2,&sbuf);
|
||||
|
||||
/* Open file in dos compatibility share mode. */
|
||||
/* We should fail if file exists. */
|
||||
fsp = open_file_shared(conn,fname2,&sbuf,SET_DENY_MODE(DENY_FCB)|SET_OPEN_MODE(DOS_OPEN_FCB),
|
||||
(FILE_CREATE_IF_NOT_EXIST|FILE_EXISTS_FAIL), unixmode, oplock_request, NULL, NULL);
|
||||
/* We should fail if file does not exist. */
|
||||
fsp = open_file_shared(conn,fname,&sbuf,
|
||||
SET_DENY_MODE(DENY_FCB)|SET_OPEN_MODE(DOS_OPEN_FCB),
|
||||
FILE_FAIL_IF_NOT_EXIST,
|
||||
unixmode, oplock_request, NULL, NULL);
|
||||
|
||||
/* close fd from smb_mkstemp() */
|
||||
close(tmpfd);
|
||||
|
||||
if (!fsp)
|
||||
{
|
||||
@ -3169,7 +3178,7 @@ int reply_printopen(connection_struct *conn,
|
||||
}
|
||||
|
||||
/* Open for exclusive use, write only. */
|
||||
fsp = print_fsp_open(conn,"dos.prn");
|
||||
fsp = print_fsp_open(conn);
|
||||
|
||||
if (!fsp) {
|
||||
END_PROFILE(SMBsplopen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user