summaryrefslogtreecommitdiffstats
path: root/source3/smbd/dosmode.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-03-24 22:34:28 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:18 -0500
commitfcfa75b2fc19be9abe9580efa314d4c981f80098 (patch)
treec7017020aab219e5d30d6daa5e2d675a9f882c6a /source3/smbd/dosmode.c
parent27b84e5e5573cf922b77bdf935a715af2c4ce1c2 (diff)
downloadsamba-fcfa75b2fc19be9abe9580efa314d4c981f80098.tar.gz
samba-fcfa75b2fc19be9abe9580efa314d4c981f80098.tar.xz
samba-fcfa75b2fc19be9abe9580efa314d4c981f80098.zip
r6049: Ensure "dos filetime" checks file ACLs correctly. May fix Excel "read-only"
issue. Jeremy. (This used to be commit 80e788143a6c3d973d3b8e57d91ca5c4a83605b2)
Diffstat (limited to 'source3/smbd/dosmode.c')
-rw-r--r--source3/smbd/dosmode.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index fefcaca09d5..3a0e81e5fef 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -431,10 +431,8 @@ int file_set_dosmode(connection_struct *conn, const char *fname, uint32 dosmode,
than POSIX.
*******************************************************************/
-int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
+int file_utime(connection_struct *conn, const char *fname, struct utimbuf *times)
{
- extern struct current_user current_user;
- SMB_STRUCT_STAT sb;
int ret = -1;
errno = 0;
@@ -454,21 +452,12 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
(as DOS does).
*/
- if(SMB_VFS_STAT(conn,fname,&sb) != 0)
- return -1;
-
/* Check if we have write access. */
- if (CAN_WRITE(conn)) {
- if (((sb.st_mode & S_IWOTH) || conn->admin_user ||
- ((sb.st_mode & S_IWUSR) && current_user.uid==sb.st_uid) ||
- ((sb.st_mode & S_IWGRP) &&
- in_group(sb.st_gid,current_user.gid,
- current_user.ngroups,current_user.groups)))) {
- /* We are allowed to become root and change the filetime. */
- become_root();
- ret = SMB_VFS_UTIME(conn,fname, times);
- unbecome_root();
- }
+ if (can_write_to_file(conn, fname)) {
+ /* We are allowed to become root and change the filetime. */
+ become_root();
+ ret = SMB_VFS_UTIME(conn,fname, times);
+ unbecome_root();
}
return ret;
@@ -478,7 +467,7 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times)
Change a filetime - possibly allowing DOS semantics.
*******************************************************************/
-BOOL set_filetime(connection_struct *conn, char *fname, time_t mtime)
+BOOL set_filetime(connection_struct *conn, const char *fname, time_t mtime)
{
struct utimbuf times;