summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2009-09-25 06:51:01 -0400
committerKarolin Seeger <kseeger@samba.org>2009-09-28 13:22:56 +0200
commit42351937b00f6aa013d16c2a4dbd0b37e7e9ed11 (patch)
tree4f34c89093381d83a8b477d538df79017e143cb3
parent53ba0b36d0d3bb2fb4b2fc5335920487060ed284 (diff)
downloadsamba-42351937b00f6aa013d16c2a4dbd0b37e7e9ed11.tar.gz
mount.cifs: check access of credential files before opening
It's possible for an unprivileged user to pass a setuid mount.cifs a credential or password file to which he does not have access. This can cause mount.cifs to open the file on his behalf and possibly leak the info in the first few lines of the file. Check the access permissions of the file before opening it. Reported-by: Ronald Volgers <r.c.volgers@student.utwente.nl> Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Steve French <sfrench@us.ibm.com> Part 1/2 of a fix for CVE-2009-2948.
-rw-r--r--source3/client/mount.cifs.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c
index 0c551cce755..54d59cf6371 100644
--- a/source3/client/mount.cifs.c
+++ b/source3/client/mount.cifs.c
@@ -198,6 +198,11 @@ static int open_cred_file(char * file_name)
char * temp_val;
FILE * fs;
int i, length;
+
+ i = access(file_name, R_OK);
+ if (i)
+ return i;
+
fs = fopen(file_name,"r");
if(fs == NULL)
return errno;
@@ -320,6 +325,12 @@ static int get_password_from_file(int file_descript, char * filename)
}
if(filename != NULL) {
+ rc = access(filename, R_OK);
+ if (rc) {
+ fprintf(stderr, "mount.cifs failed: access check of %s failed: %s\n",
+ filename, strerror(errno));
+ exit(EX_SYSERR);
+ }
file_descript = open(filename, O_RDONLY);
if(file_descript < 0) {
printf("mount.cifs failed. %s attempting to open password file %s\n",