summaryrefslogtreecommitdiffstats
path: root/source3/smbd/service.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-08-17 07:03:27 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-08-17 07:03:27 +0000
commit578a39d44f532a211169a7635043e2dfc18b3c65 (patch)
tree53c7f73f4e6a973147445a39b0fb93aa8497a66b /source3/smbd/service.c
parenta0171765ff080ea0510f8c4475348e6b33044b9b (diff)
downloadsamba-578a39d44f532a211169a7635043e2dfc18b3c65.tar.gz
samba-578a39d44f532a211169a7635043e2dfc18b3c65.tar.xz
samba-578a39d44f532a211169a7635043e2dfc18b3c65.zip
smbd/auth_server: Doco, we want to use cli_nt_error here soon
smbd/password.c: We don't use globals here anymore smbd/reply.c: Tidyness, global_myworkgroup must die! smbd/service.c: Move some of the make_connection code into a helper function. (This used to be commit 15c87e404fcaff9e360a40b8b673938c6e611daf)
Diffstat (limited to 'source3/smbd/service.c')
-rw-r--r--source3/smbd/service.c73
1 files changed, 43 insertions, 30 deletions
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 13a6a387aeb..fe0f95ba6ac 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -214,6 +214,47 @@ int find_service(char *service)
/****************************************************************************
+ do some basic sainity checks on the share.
+ This function modifies dev, ecode.
+****************************************************************************/
+static BOOL share_sanity_checks(int snum, char* service, char *dev, int *ecode)
+{
+
+ if (!lp_snum_ok(snum) ||
+ !check_access(smbd_server_fd(),
+ lp_hostsallow(snum), lp_hostsdeny(snum))) {
+ *ecode = ERRaccess;
+ return False;
+ }
+
+ /* you can only connect to the IPC$ service as an ipc device */
+ if (strequal(service,"IPC$") || strequal(service,"ADMIN$"))
+ pstrcpy(dev,"IPC");
+
+ if (*dev == '?' || !*dev) {
+ if (lp_print_ok(snum)) {
+ pstrcpy(dev,"LPT1:");
+ } else {
+ pstrcpy(dev,"A:");
+ }
+ }
+
+ /* if the request is as a printer and you can't print then refuse */
+ strupper(dev);
+ if (!lp_print_ok(snum) && (strncmp(dev,"LPT",3) == 0)) {
+ DEBUG(1,("Attempt to connect to non-printer as a printer\n"));
+ *ecode = ERRinvdevice;
+ return False;
+ }
+
+ /* Behave as a printer if we are supposed to */
+ if (lp_print_ok(snum) && (strcmp(dev, "A:") == 0)) {
+ pstrcpy(dev, "LPT1:");
+ }
+ return True;
+}
+
+/****************************************************************************
make a connection to a service
****************************************************************************/
connection_struct *make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid, int *ecode)
@@ -268,37 +309,9 @@ connection_struct *make_connection(char *service,char *user,char *password, int
}
}
- if (!lp_snum_ok(snum) ||
- !check_access(smbd_server_fd(),
- lp_hostsallow(snum), lp_hostsdeny(snum))) {
- *ecode = ERRaccess;
- return NULL;
- }
-
- /* you can only connect to the IPC$ service as an ipc device */
- if (strequal(service,"IPC$") || strequal(service,"ADMIN$"))
- pstrcpy(dev,"IPC");
-
- if (*dev == '?' || !*dev) {
- if (lp_print_ok(snum)) {
- pstrcpy(dev,"LPT1:");
- } else {
- pstrcpy(dev,"A:");
- }
- }
-
- /* if the request is as a printer and you can't print then refuse */
- strupper(dev);
- if (!lp_print_ok(snum) && (strncmp(dev,"LPT",3) == 0)) {
- DEBUG(1,("Attempt to connect to non-printer as a printer\n"));
- *ecode = ERRinvdevice;
+ if (!share_sanity_checks(snum, service, dev, ecode)) {
return NULL;
- }
-
- /* Behave as a printer if we are supposed to */
- if (lp_print_ok(snum) && (strcmp(dev, "A:") == 0)) {
- pstrcpy(dev, "LPT1:");
- }
+ }
/* lowercase the user name */
strlower(user);