summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-08-17 07:48:25 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-08-17 07:48:25 +0000
commit67967749a2ed584de3b0d670094724021eafc50b (patch)
tree07286a7d373db662cfb4f976ef65f44ec56fbe6e /source3/smbd
parent7c332851b0ac4eab77f6e449cefd48f119c7ddf6 (diff)
downloadsamba-67967749a2ed584de3b0d670094724021eafc50b.tar.gz
samba-67967749a2ed584de3b0d670094724021eafc50b.tar.bz2
samba-67967749a2ed584de3b0d670094724021eafc50b.zip
Move read only check into a helper funcion. Ensure conn->service is set
before we use it to find a share's details. (This used to be commit 7dc716f174c38e73b8e6d07130a1bc39f4499ce3)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/service.c90
1 files changed, 50 insertions, 40 deletions
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index fe0f95ba6a..5bb535f884 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -254,6 +254,37 @@ static BOOL share_sanity_checks(int snum, char* service, char *dev, int *ecode)
return True;
}
+
+/****************************************************************************
+ readonly share?
+****************************************************************************/
+static void set_read_only(connection_struct *conn)
+{
+ char *service = lp_servicename(conn->service);
+ conn->read_only = lp_readonly(conn->service);
+
+ {
+ char **list;
+
+ lp_list_copy(&list, lp_readlist(conn->service));
+ if(list && lp_list_substitute(list, "%S", service)) {
+ if (user_in_list(conn->user, list))
+ conn->read_only = True;
+ }
+ else DEBUG(0, ("ERROR: read list substitution failed\n"));
+ if (list) lp_list_free(&list);
+
+ lp_list_copy(&list, lp_writelist(conn->service));
+ if(list && lp_list_substitute(list, "%S", service)) {
+ if (user_in_list(conn->user, list))
+ conn->read_only = False;
+ }
+ else DEBUG(0, ("ERROR: write list substitution failed\n"));
+ if (list) lp_list_free(&list);
+ }
+}
+
+
/****************************************************************************
make a connection to a service
****************************************************************************/
@@ -346,46 +377,6 @@ connection_struct *make_connection(char *service,char *user,char *password, int
return NULL;
}
- conn->read_only = lp_readonly(snum);
-
-
- {
- char **list;
-
- lp_list_copy(&list, lp_readlist(snum));
- if(list && lp_list_substitute(list, "%S", service)) {
- if (user_in_list(user, list))
- conn->read_only = True;
- }
- else DEBUG(0, ("ERROR: read list substitution failed\n"));
- if (list) lp_list_free(&list);
-
- lp_list_copy(&list, lp_writelist(snum));
- if(list && lp_list_substitute(list, "%S", service)) {
- if (user_in_list(user, list))
- conn->read_only = False;
- }
- else DEBUG(0, ("ERROR: write list substitution failed\n"));
- if (list) lp_list_free(&list);
- }
-
- /* admin user check */
-
- /* JRA - original code denied admin user if the share was
- marked read_only. Changed as I don't think this is needed,
- but old code left in case there is a problem here.
- */
- if (user_in_list(user, lp_admin_users(snum))
-#if 0
- && !conn->read_only
-#endif
- ) {
- conn->admin_user = True;
- DEBUG(0,("%s logged in as admin user (root privileges)\n",user));
- } else {
- conn->admin_user = False;
- }
-
conn->force_user = force;
conn->vuid = vuid;
conn->uid = pass->pw_uid;
@@ -405,6 +396,25 @@ connection_struct *make_connection(char *service,char *user,char *password, int
string_set(&conn->user,user);
conn->nt_user_token = NULL;
+ set_read_only(conn);
+
+ /* admin user check */
+
+ /* JRA - original code denied admin user if the share was
+ marked read_only. Changed as I don't think this is needed,
+ but old code left in case there is a problem here.
+ */
+ if (user_in_list(user, lp_admin_users(snum))
+#if 0
+ && !conn->read_only
+#endif
+ ) {
+ conn->admin_user = True;
+ DEBUG(0,("%s logged in as admin user (root privileges)\n",user));
+ } else {
+ conn->admin_user = False;
+ }
+
/*
* If force user is true, then store the
* given userid and also the primary groupid