DEBUG(5,("delete_share_file: Deleted share file %s\n", fname));
}
- /* return to our previous privilage level */
+ /* return to our previous privilege level */
unbecome_root(False);
return 0;
/* At this point we have an open fd to the share mode file.
Lock the first byte exclusively to signify a lock. */
- if(conn->vfs_ops.lock(fd, SMB_F_SETLKW, 0, 1, F_WRLCK) == False)
+ if(fcntl_lock(fd, SMB_F_SETLKW, 0, 1, F_WRLCK) == False)
{
DEBUG(0,("ERROR lock_share_entry: fcntl_lock on file %s failed with %s\n",
fname, strerror(errno)));
*ptok = (int)fd;
- /* return to our previous privilage level */
+ /* return to our previous privilege level */
unbecome_root(False);
return ret;
/* token is the fd of the open share mode file. */
/* Unlock the first byte. */
- if(conn->vfs_ops.lock(fd, SMB_F_SETLKW, 0, 1, F_UNLCK) == False)
+ if(fcntl_lock(fd, SMB_F_SETLKW, 0, 1, F_UNLCK) == False)
{
DEBUG(0,("ERROR unlock_share_entry: fcntl_lock failed with %s\n",
strerror(errno)));
for( i = 0; i < num_entries; i++)
{
- int pid;
+ pid_t pid;
char *p = base + (i*SMF_ENTRY_LENGTH);
- pid = IVAL(p,SME_PID_OFFSET);
+ pid = (pid_t)IVAL(p,SME_PID_OFFSET);
if(!process_exists(pid))
{
DEBUG(0,("get_share_modes: process %d no longer exists and \
it left a share mode entry with mode 0x%X in share file %s\n",
- pid, IVAL(p,SME_SHAREMODE_OFFSET), fname));
+ (int)pid, IVAL(p,SME_SHAREMODE_OFFSET), fname));
continue;
}
share_array[num_entries_copied].time.tv_sec = IVAL(p,SME_SEC_OFFSET);
{
char *p = base + (i*SMF_ENTRY_LENGTH);
- SIVAL(p,SME_PID_OFFSET,share_array[i].pid);
+ SIVAL(p,SME_PID_OFFSET,(uint32)share_array[i].pid);
SIVAL(p,SME_SHAREMODE_OFFSET,share_array[i].share_mode);
SIVAL(p,SME_SEC_OFFSET,share_array[i].time.tv_sec);
SIVAL(p,SME_USEC_OFFSET,share_array[i].time.tv_usec);
return 0;
}
/* Now truncate the file at this point. */
+#ifdef FTRUNCATE_NEEDS_ROOT
+ become_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
if(sys_ftruncate(fd, (SMB_OFF_T)newsize)!= 0)
{
+#ifdef FTRUNCATE_NEEDS_ROOT
+ int saved_errno = errno;
+ unbecome_root(False);
+ errno = saved_errno;
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
DEBUG(0,("ERROR: get_share_modes: failed to ftruncate share \
mode file %s to size %d (%s)\n", fname, newsize, strerror(errno)));
if(*old_shares)
}
}
+#ifdef FTRUNCATE_NEEDS_ROOT
+ unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
if(buf)
free(buf);
int num_entries;
int newsize;
int i;
- int pid;
+ pid_t pid;
BOOL deleted = False;
BOOL new_file;
if((IVAL(p,SME_SEC_OFFSET) != fsp->open_time.tv_sec) ||
(IVAL(p,SME_USEC_OFFSET) != fsp->open_time.tv_usec) ||
(IVAL(p,SME_SHAREMODE_OFFSET) != fsp->share_mode) ||
- (IVAL(p,SME_PID_OFFSET) != pid))
+ (((pid_t)IVAL(p,SME_PID_OFFSET)) != pid))
continue;
DEBUG(5,("del_share_mode: deleting entry number %d (of %d) from the share file %s\n",
}
/* Now truncate the file at this point. */
+#ifdef FTRUNCATE_NEEDS_ROOT
+ become_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
if(sys_ftruncate(fd, (SMB_OFF_T)newsize) != 0)
{
+#ifdef FTRUNCATE_NEEDS_ROOT
+ int saved_errno = errno;
+ unbecome_root(False);
+ errno = saved_errno;
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
+
DEBUG(0,("ERROR: del_share_mode: failed to ftruncate share \
mode file %s to size %d (%s)\n", fname, newsize, strerror(errno)));
if(buf)
free(buf);
return;
}
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+ unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
}
/*******************************************************************
{
pstring fname;
int fd = (int)token;
- int pid = (int)getpid();
+ pid_t pid = getpid();
SMB_STRUCT_STAT sb;
char *buf;
int num_entries;
share_name(fsp->conn, fsp->fd_ptr->dev,
fsp->fd_ptr->inode, fname);
- if(fsp->conn->vfs_ops.fstat_file(fd, &sb) != 0)
+ if(sys_fstat(fd, &sb) != 0)
{
DEBUG(0,("ERROR: set_share_mode: Failed to do stat on share file %s\n",
fname));
{
/* New file - just use a single_entry. */
if((buf = (char *)malloc(SMF_HEADER_LENGTH +
- strlen(fsp->fsp_name) + 1 + SMF_ENTRY_LENGTH)) == NULL)
+ strlen(fsp->fsp_name) + strlen(fsp->conn->connectpath) + 2 + SMF_ENTRY_LENGTH)) == NULL)
{
DEBUG(0,("ERROR: set_share_mode: malloc failed for single entry.\n"));
return False;
}
SIVAL(buf,SMF_VERSION_OFFSET,LOCKING_VERSION);
SIVAL(buf,SMF_NUM_ENTRIES_OFFSET,0);
- SSVAL(buf,SMF_FILENAME_LEN_OFFSET,strlen(fsp->fsp_name) + 1);
- pstrcpy(buf + SMF_HEADER_LENGTH, fsp->fsp_name);
+ SSVAL(buf,SMF_FILENAME_LEN_OFFSET,strlen(fsp->fsp_name) + strlen(fsp->conn->connectpath) + 2);
+ pstrcpy(buf + SMF_HEADER_LENGTH, fsp->conn->connectpath);
+ pstrcat(buf + SMF_HEADER_LENGTH, "/");
+ pstrcat(buf + SMF_HEADER_LENGTH, fsp->fsp_name);
}
num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
SIVAL(p,SME_SEC_OFFSET,fsp->open_time.tv_sec);
SIVAL(p,SME_USEC_OFFSET,fsp->open_time.tv_usec);
SIVAL(p,SME_SHAREMODE_OFFSET,fsp->share_mode);
- SIVAL(p,SME_PID_OFFSET,pid);
+ SIVAL(p,SME_PID_OFFSET,(uint32)pid);
SSVAL(p,SME_PORT_OFFSET,port);
SSVAL(p,SME_OPLOCK_TYPE_OFFSET,op_type);
/* Now truncate the file at this point - just for safety. */
+#ifdef FTRUNCATE_NEEDS_ROOT
+ become_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
if(sys_ftruncate(fd, (SMB_OFF_T)(header_size + (SMF_ENTRY_LENGTH*num_entries)))!= 0)
{
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+ int saved_errno = errno;
+ unbecome_root(False);
+ errno = saved_errno;
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
DEBUG(0,("ERROR: set_share_mode: failed to ftruncate share \
mode file %s to size %d (%s)\n", fname, header_size + (SMF_ENTRY_LENGTH*num_entries),
strerror(errno)));
return False;
}
+#ifdef FTRUNCATE_NEEDS_ROOT
+ unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
if(buf)
free(buf);
DEBUG(3,("set_share_mode: Created share file %s with \
-mode 0x%X pid=%d\n",fname,fsp->share_mode,pid));
+mode 0x%X pid=%d\n",fname,fsp->share_mode,(int)pid));
return True;
}
int num_entries;
int fsize;
int i;
- int pid;
+ pid_t pid;
BOOL found = False;
BOOL new_file;
share_mode_entry entry;
if((IVAL(p,SME_SEC_OFFSET) != fsp->open_time.tv_sec) ||
(IVAL(p,SME_USEC_OFFSET) != fsp->open_time.tv_usec) ||
(IVAL(p,SME_SHAREMODE_OFFSET) != fsp->share_mode) ||
- (IVAL(p,SME_PID_OFFSET) != pid))
+ (((pid_t)IVAL(p,SME_PID_OFFSET)) != pid))
continue;
DEBUG(5,("slow_mod_share_entry: Calling generic function to modify entry number %d (of %d) \
* the generic function with the given parameter.
*/
- entry.pid = IVAL(p,SME_PID_OFFSET);
+ entry.pid = (pid_t)IVAL(p,SME_PID_OFFSET);
entry.op_port = SVAL(p,SME_PORT_OFFSET);
entry.op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
entry.share_mode = IVAL(p,SME_SHAREMODE_OFFSET);
- entry.time.tv_sec = IVAL(p,SME_SEC_OFFSET)
- entry.time.tv_sec = IVAL(p,SME_USEC_OFFSET);
+ entry.time.tv_sec = IVAL(p,SME_SEC_OFFSET);
+ entry.time.tv_usec = IVAL(p,SME_USEC_OFFSET);
(*mod_fn)( &entry, fsp->fd_ptr->dev, fsp->fd_ptr->inode, param);
* Now copy any changes the function made back into the buffer.
*/
- SIVAL(p,SME_PID_OFFSET, entry.pid)
+ SIVAL(p,SME_PID_OFFSET, (uint32)entry.pid);
SSVAL(p,SME_PORT_OFFSET,entry.op_port);
SSVAL(p,SME_OPLOCK_TYPE_OFFSET,entry.op_type);
SIVAL(p,SME_SHAREMODE_OFFSET,entry.share_mode);
- SIVAL(p,SME_SEC_OFFSET,entry.time.tv_sec)
- SIVAL(p,SME_USEC_OFFSET,entry.time.tv_sec);
+ SIVAL(p,SME_SEC_OFFSET,entry.time.tv_sec);
+ SIVAL(p,SME_USEC_OFFSET,entry.time.tv_usec);
found = True;
break;
/*******************************************************************
call the specified function on each entry under management by the
-share ode system
+share mode system
********************************************************************/
static int slow_share_forall(void (*fn)(share_mode_entry *, char *))
{
SVAL(buf,SMF_FILENAME_LEN_OFFSET);
for( i = 0; i < IVAL(buf, SMF_NUM_ENTRIES_OFFSET); i++) {
char *p = base + (i*SMF_ENTRY_LENGTH);
- e.pid = IVAL(p,SME_PID_OFFSET);
+ e.pid = (pid_t)IVAL(p,SME_PID_OFFSET);
e.share_mode = IVAL(p,SME_SHAREMODE_OFFSET);
e.time.tv_sec = IVAL(p,SME_SEC_OFFSET);
e.time.tv_usec = IVAL(p,SME_USEC_OFFSET);
e.op_port = SVAL(p,SME_PORT_OFFSET);
- e.pid = SVAL(p,SME_PID_OFFSET);
e.op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
if (process_exists(e.pid)) {