summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-04-18 05:12:46 +0000
committerJeremy Allison <jra@samba.org>2001-04-18 05:12:46 +0000
commit6f78636a56106c510545dc1c8218b3a90a486c67 (patch)
treef8f9bdb15d1cdb94f030a9b4bacc7bbfe0f21ad3
parenta40fe7b47d269d294b1bbf5c22d9a6d6c9f81e17 (diff)
downloadsamba-6f78636a56106c510545dc1c8218b3a90a486c67.tar.gz
samba-6f78636a56106c510545dc1c8218b3a90a486c67.tar.bz2
samba-6f78636a56106c510545dc1c8218b3a90a486c67.zip
Removed mktemp from HEAD - same as done in 2.2.
Jeremy. (This used to be commit 121b59669fbcd1aaedb08011ff36169fc6561c55)
-rw-r--r--source3/include/proto.h24
-rw-r--r--source3/lib/util.c43
-rw-r--r--source3/printing/printfsp.c4
-rw-r--r--source3/printing/printing.c23
-rw-r--r--source3/smbd/open.c2
-rw-r--r--source3/smbd/reply.c23
6 files changed, 52 insertions, 67 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c9c508be6c..2497169677 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -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 */
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 3dd7fad8fc..3bee53abbc 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.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)
{
@@ -1739,34 +1733,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
*****************************************************************/
int smb_mkstemp(char *template)
@@ -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
diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c
index 6a8e4bea45..6545dc59c2 100644
--- a/source3/printing/printfsp.c
+++ b/source3/printing/printfsp.c
@@ -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(&current_user, SNUM(conn), jobname);
+ jobid = print_job_start(&current_user, SNUM(conn), "smb.prn");
if (jobid == -1) {
file_free(fsp);
return NULL;
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 753d0f7f96..d98c7c4d4c 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -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) {
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index c6d4a44688..8db4400664 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -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);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9d517dcaa9..82ac230764 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -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);