aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorShirish Pargaonkar <shirishpargaonkar@gmail.com>2011-09-26 10:56:44 -0400
committerSteve French <smfrench@gmail.com>2011-10-13 00:42:17 -0400
commit3d3ea8e64efbeb3e4289675dbbfab82333395642 (patch)
tree3f7c52039dceefeae2abf010a1a3ec8abef0c459 /fs/cifs/file.c
parent8bc4392a1e50f346e97f8777aaefd9cfc3d45c9f (diff)
cifs: Add mount options for backup intent (try #6)
Add mount options backupuid and backugid. It allows an authenticated user to access files with the intent to back them up including their ACLs, who may not have access permission but has "Backup files and directories user right" on them (by virtue of being part of the built-in group Backup Operators. When mount options backupuid is specified, cifs client restricts the use of backup intents to the user whose effective user id is specified along with the mount option. When mount options backupgid is specified, cifs client restricts the use of backup intents to the users whose effective user id belongs to the group id specified along with the mount option. If an authenticated user is not part of the built-in group Backup Operators at the server, access to such files is denied, even if allowed by the client. Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 8e184150cfb5..237192ae7587 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -174,6 +174,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
174 int rc; 174 int rc;
175 int desiredAccess; 175 int desiredAccess;
176 int disposition; 176 int disposition;
177 int create_options = CREATE_NOT_DIR;
177 FILE_ALL_INFO *buf; 178 FILE_ALL_INFO *buf;
178 179
179 desiredAccess = cifs_convert_flags(f_flags); 180 desiredAccess = cifs_convert_flags(f_flags);
@@ -210,9 +211,12 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
210 if (!buf) 211 if (!buf)
211 return -ENOMEM; 212 return -ENOMEM;
212 213
214 if (backup_cred(cifs_sb))
215 create_options |= CREATE_OPEN_BACKUP_INTENT;
216
213 if (tcon->ses->capabilities & CAP_NT_SMBS) 217 if (tcon->ses->capabilities & CAP_NT_SMBS)
214 rc = CIFSSMBOpen(xid, tcon, full_path, disposition, 218 rc = CIFSSMBOpen(xid, tcon, full_path, disposition,
215 desiredAccess, CREATE_NOT_DIR, pnetfid, poplock, buf, 219 desiredAccess, create_options, pnetfid, poplock, buf,
216 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags 220 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
217 & CIFS_MOUNT_MAP_SPECIAL_CHR); 221 & CIFS_MOUNT_MAP_SPECIAL_CHR);
218 else 222 else
@@ -465,6 +469,7 @@ static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)
465 char *full_path = NULL; 469 char *full_path = NULL;
466 int desiredAccess; 470 int desiredAccess;
467 int disposition = FILE_OPEN; 471 int disposition = FILE_OPEN;
472 int create_options = CREATE_NOT_DIR;
468 __u16 netfid; 473 __u16 netfid;
469 474
470 xid = GetXid(); 475 xid = GetXid();
@@ -524,6 +529,9 @@ static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)
524 529
525 desiredAccess = cifs_convert_flags(pCifsFile->f_flags); 530 desiredAccess = cifs_convert_flags(pCifsFile->f_flags);
526 531
532 if (backup_cred(cifs_sb))
533 create_options |= CREATE_OPEN_BACKUP_INTENT;
534
527 /* Can not refresh inode by passing in file_info buf to be returned 535 /* Can not refresh inode by passing in file_info buf to be returned
528 by SMBOpen and then calling get_inode_info with returned buf 536 by SMBOpen and then calling get_inode_info with returned buf
529 since file might have write behind data that needs to be flushed 537 since file might have write behind data that needs to be flushed
@@ -531,7 +539,7 @@ static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)
531 that inode was not dirty locally we could do this */ 539 that inode was not dirty locally we could do this */
532 540
533 rc = CIFSSMBOpen(xid, tcon, full_path, disposition, desiredAccess, 541 rc = CIFSSMBOpen(xid, tcon, full_path, disposition, desiredAccess,
534 CREATE_NOT_DIR, &netfid, &oplock, NULL, 542 create_options, &netfid, &oplock, NULL,
535 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 543 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
536 CIFS_MOUNT_MAP_SPECIAL_CHR); 544 CIFS_MOUNT_MAP_SPECIAL_CHR);
537 if (rc) { 545 if (rc) {