Changeset 312
- Timestamp:
- Aug 5, 2009, 6:34:45 PM (16 years ago)
- Location:
- branches/samba-3.0/source
- Files:
-
- 4 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/Makefile.in
r165 r312 145 145 # Note that all executable programs now provide for an optional executable suffix. 146 146 147 SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ bin/swat@EXEEXT@ @EXTRA_SBIN_PROGS@ @CIFSUPCALL_PROGS@147 SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ bin/swat@EXEEXT@ @EXTRA_SBIN_PROGS@ 148 148 149 149 ROOT_SBIN_PROGS = @CIFSMOUNT_PROGS@ … … 1600 1600 1601 1601 installcifsupcall: @CIFSUPCALL_PROGS@ 1602 @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS _BIN) $(DESTDIR) $(SBINDIR)1603 @$(SHELL) script/installbin.sh $(INSTALLPERMS _BIN) $(DESTDIR) $(prefix) $(SBINDIR) @CIFSUPCALL_PROGS@1602 @$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS) $(DESTDIR) $(SBINDIR) 1603 @$(SHELL) script/installbin.sh $(INSTALLPERMS) $(DESTDIR) $(prefix) $(SBINDIR) @CIFSUPCALL_PROGS@ 1604 1604 1605 1605 # Some symlinks are required for the 'probing' of modules. … … 1735 1735 1736 1736 uninstallcifsupcall: 1737 @$(SHELL) script/uninstallbin.sh $(INSTALLPERMS _BIN) $(DESTDIR) $(prefix) $(ROOTSBINDIR) @CIFSUPCALL_PROGS@1737 @$(SHELL) script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR) $(prefix) $(ROOTSBINDIR) @CIFSUPCALL_PROGS@ 1738 1738 1739 1739 uninstallmodules: -
branches/samba-3.0/source/VERSION
r286 r312 26 26 SAMBA_VERSION_MAJOR=3 27 27 SAMBA_VERSION_MINOR=0 28 SAMBA_VERSION_RELEASE=3 528 SAMBA_VERSION_RELEASE=36 29 29 30 30 ######################################################## … … 96 96 # -> "CVS 3.0.0rc2-VendorVersion" # 97 97 ######################################################## 98 SAMBA_VERSION_VENDOR_SUFFIX= 98 SAMBA_VERSION_VENDOR_SUFFIX="eCS 1.0.2" 99 99 SAMBA_VERSION_VENDOR_PATCH= -
branches/samba-3.0/source/client/mount.cifs.c
r165 r312 2 2 Mount helper utility for Linux CIFS VFS (virtual filesystem) client 3 3 Copyright (C) 2003,2008 Steve French (sfrench@us.ibm.com) 4 Copyright (C) 2008 Jeremy Allison (jra@samba.org) 4 5 5 6 This program is free software; you can redistribute it and/or modify 6 7 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2of the License, or8 the Free Software Foundation; either version 3 of the License, or 8 9 (at your option) any later version. 9 10 … … 14 15 15 16 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 18 19 19 #ifndef _GNU_SOURCE … … 58 58 #endif /* MOUNT_CIFS_VENDOR_SUFFIX */ 59 59 60 #ifdef _SAMBA_BUILD_ 61 #include "include/config.h" 62 #endif 63 60 64 #ifndef MS_MOVE 61 65 #define MS_MOVE 8192 … … 70 74 #define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr))) 71 75 76 #ifndef SAFE_FREE 77 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) 78 #endif 79 80 #define MOUNT_PASSWD_SIZE 64 81 #define DOMAIN_SIZE 64 82 83 /* currently maximum length of IPv6 address string */ 84 #define MAX_ADDRESS_LEN INET6_ADDRSTRLEN 85 72 86 const char *thisprogram; 73 87 int verboseflag = 0; 88 int fakemnt = 0; 74 89 static int got_password = 0; 75 90 static int got_user = 0; … … 89 104 /* like strncpy but does not 0 fill the buffer and always null 90 105 * terminates. bufsize is the size of the destination buffer */ 106 107 #ifndef HAVE_STRLCPY 91 108 static size_t strlcpy(char *d, const char *s, size_t bufsize) 92 109 { … … 99 116 return ret; 100 117 } 118 #endif 101 119 102 120 /* like strncat but does not 0 fill the buffer and always null 103 121 * terminates. bufsize is the length of the buffer, which should 104 122 * be one more than the maximum resulting string length */ 123 124 #ifndef HAVE_STRLCAT 105 125 static size_t strlcat(char *d, const char *s, size_t bufsize) 106 126 { … … 121 141 return ret; 122 142 } 143 #endif 123 144 124 145 /* BB finish BB … … 143 164 printf("\n\tcredentials=<filename>,guest,perm,noperm,setuids,nosetuids,rw,ro,"); 144 165 printf("\n\tsep=<char>,iocharset=<codepage>,suid,nosuid,exec,noexec,serverino,"); 145 printf("\n\tdirectio,mapchars,nomapchars,nolock,servernetbiosname=<SRV_RFC1001NAME>"); 166 printf("\n\tmapchars,nomapchars,nolock,servernetbiosname=<SRV_RFC1001NAME>"); 167 printf("\n\tdirectio,nounix,cifsacl,sec=<authentication mechanism>,sign"); 146 168 printf("\n\nOptions not needed for servers supporting CIFS Unix extensions"); 147 169 printf("\n\t(e.g. unneeded for mounts to most Samba versions):"); … … 150 172 printf("\n\tport=<tcpport>,rsize=<size>,wsize=<size>,unc=<unc_name>,ip=<ip_address>,"); 151 173 printf("\n\tdev,nodev,nouser_xattr,netbiosname=<OUR_RFC1001NAME>,hard,soft,intr,"); 152 printf("\n\tnointr,ignorecase,noposixpaths,noacl"); 174 printf("\n\tnointr,ignorecase,noposixpaths,noacl,prefixpath=<path>,nobrl"); 175 printf("\n\tin6_addr"); 153 176 printf("\n\nOptions are described in more detail in the manual page"); 154 177 printf("\n\tman 8 mount.cifs\n"); … … 156 179 printf("\n\t%s -V\n",thisprogram); 157 180 158 if(mountpassword) { 159 memset(mountpassword,0,64); 160 free(mountpassword); 161 mountpassword = NULL; 162 } 181 SAFE_FREE(mountpassword); 163 182 exit(EX_USAGE); 164 183 } … … 173 192 } 174 193 return username; 175 }176 177 static char * parse_cifs_url(char * unc_name)178 {179 printf("\nMounting cifs URL not implemented yet. Attempt to mount %s\n",unc_name);180 return NULL;181 194 } 182 195 … … 193 206 if(line_buf == NULL) { 194 207 fclose(fs); 195 return -ENOMEM;208 return ENOMEM; 196 209 } 197 210 … … 213 226 if ((temp_val[length] == '\n') 214 227 || (temp_val[length] == '\0')) { 228 temp_val[length] = '\0'; 215 229 break; 216 230 } … … 219 233 printf("mount.cifs failed due to malformed username in credentials file"); 220 234 memset(line_buf,0,4096); 221 if(mountpassword) {222 memset(mountpassword,0,64);223 }224 235 exit(EX_USAGE); 225 236 } else { … … 228 239 /* BB adding free of user_name string before exit, 229 240 not really necessary but would be cleaner */ 230 str ncpy(user_name,temp_val, length);241 strlcpy(user_name,temp_val, length+1); 231 242 } 232 243 } … … 236 247 /* go past equals sign */ 237 248 temp_val++; 238 for(length = 0;length< 65;length++) {249 for(length = 0;length<MOUNT_PASSWD_SIZE+1;length++) { 239 250 if ((temp_val[length] == '\n') 240 251 || (temp_val[length] == '\0')) { 252 temp_val[length] = '\0'; 241 253 break; 242 254 } 243 255 } 244 if(length > 64) {256 if(length > MOUNT_PASSWD_SIZE) { 245 257 printf("mount.cifs failed: password in credentials file too long\n"); 246 258 memset(line_buf,0, 4096); 247 if(mountpassword) {248 memset(mountpassword,0,64);249 }250 259 exit(EX_USAGE); 251 260 } else { 252 261 if(mountpassword == NULL) { 253 mountpassword = (char *)calloc( 65,1);262 mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); 254 263 } else 255 memset(mountpassword,0, 64);264 memset(mountpassword,0,MOUNT_PASSWD_SIZE); 256 265 if(mountpassword) { 257 str ncpy(mountpassword,temp_val,length);266 strlcpy(mountpassword,temp_val,MOUNT_PASSWD_SIZE+1); 258 267 got_password = 1; 259 268 } … … 267 276 if(verboseflag) 268 277 printf("\nDomain %s\n",temp_val); 269 for(length = 0;length< 65;length++) {278 for(length = 0;length<DOMAIN_SIZE+1;length++) { 270 279 if ((temp_val[length] == '\n') 271 280 || (temp_val[length] == '\0')) { 281 temp_val[length] = '\0'; 272 282 break; 273 283 } 274 284 } 275 if(length > 64) {285 if(length > DOMAIN_SIZE) { 276 286 printf("mount.cifs failed: domain in credentials file too long\n"); 277 if(mountpassword) {278 memset(mountpassword,0,64);279 }280 287 exit(EX_USAGE); 281 288 } else { 282 289 if(domain_name == NULL) { 283 domain_name = (char *)calloc( 65,1);290 domain_name = (char *)calloc(DOMAIN_SIZE+1,1); 284 291 } else 285 memset(domain_name,0, 64);292 memset(domain_name,0,DOMAIN_SIZE); 286 293 if(domain_name) { 287 str ncpy(domain_name,temp_val,length);294 strlcpy(domain_name,temp_val,DOMAIN_SIZE+1); 288 295 got_domain = 1; 289 296 } … … 294 301 } 295 302 fclose(fs); 296 if(line_buf) { 297 memset(line_buf,0,4096); 298 free(line_buf); 299 line_buf = NULL; 300 } 303 SAFE_FREE(line_buf); 301 304 return 0; 302 305 } … … 309 312 310 313 if(mountpassword == NULL) 311 mountpassword = (char *)calloc( 65,1);314 mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); 312 315 else 313 memset(mountpassword, 0, 64);316 memset(mountpassword, 0, MOUNT_PASSWD_SIZE); 314 317 315 318 if (mountpassword == NULL) { … … 328 331 /* else file already open and fd provided */ 329 332 330 for(i=0;i< 64;i++) {333 for(i=0;i<MOUNT_PASSWD_SIZE;i++) { 331 334 rc = read(file_descript,&c,1); 332 335 if(rc < 0) { 333 336 printf("mount.cifs failed. Error %s reading password file\n",strerror(errno)); 334 memset(mountpassword,0,64);335 337 if(filename != NULL) 336 338 close(file_descript); … … 344 346 } else /* read valid character */ { 345 347 if((c == 0) || (c == '\n')) { 348 mountpassword[i] = '\0'; 346 349 break; 347 350 } else … … 349 352 } 350 353 } 351 if((i == 64) && (verboseflag)) { 352 printf("\nWarning: password longer than 64 characters specified in cifs password file"); 354 if((i == MOUNT_PASSWD_SIZE) && (verboseflag)) { 355 printf("\nWarning: password longer than %d characters specified in cifs password file", 356 MOUNT_PASSWD_SIZE); 353 357 } 354 358 got_password = 1; … … 428 432 } else { 429 433 printf("username specified with no parameter\n"); 434 SAFE_FREE(out); 430 435 return 1; /* needs_arg; */ 431 436 } … … 437 442 *percent_char = ','; 438 443 if(mountpassword == NULL) 439 mountpassword = (char *)calloc( 65,1);444 mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); 440 445 if(mountpassword) { 441 446 if(got_password) … … 443 448 got_password = 1; 444 449 percent_char++; 445 str ncpy(mountpassword, percent_char,64);450 strlcpy(mountpassword, percent_char,MOUNT_PASSWD_SIZE+1); 446 451 /* remove password from username */ 447 452 while(*percent_char != 0) { … … 460 465 } else { 461 466 printf("username too long\n"); 467 SAFE_FREE(out); 462 468 return 1; 463 469 } … … 475 481 } else { 476 482 printf("password too long\n"); 483 SAFE_FREE(out); 477 484 return 1; 478 485 } … … 486 493 if (!value || !*value) { 487 494 printf("target ip address argument missing"); 488 } else if (strnlen(value, 35) < 35) {495 } else if (strnlen(value, MAX_ADDRESS_LEN) <= MAX_ADDRESS_LEN) { 489 496 if(verboseflag) 490 497 printf("ip address %s override specified\n",value); … … 492 499 } else { 493 500 printf("ip address too long\n"); 501 SAFE_FREE(out); 494 502 return 1; 495 503 } … … 499 507 if (!value || !*value) { 500 508 printf("invalid path to network resource\n"); 509 SAFE_FREE(out); 501 510 return 1; /* needs_arg; */ 502 511 } else if(strnlen(value,5) < 5) { … … 513 522 } else if (strncmp(value, "\\\\", 2) != 0) { 514 523 printf("UNC Path does not begin with // or \\\\ \n"); 524 SAFE_FREE(out); 515 525 return 1; 516 526 } else { … … 522 532 } else { 523 533 printf("CIFS: UNC name too long\n"); 534 SAFE_FREE(out); 524 535 return 1; 525 536 } 526 } else if ((strncmp(data, "domain", 3) == 0) 527 || (strncmp(data, "workgroup", 5) == 0)) { 537 } else if ((strncmp(data, "dom" /* domain */, 3) == 0) 538 || (strncmp(data, "workg", 5) == 0)) { 539 /* note this allows for synonyms of "domain" 540 such as "DOM" and "dom" and "workgroup" 541 and "WORKGRP" etc. */ 528 542 if (!value || !*value) { 529 543 printf("CIFS: invalid domain name\n"); 544 SAFE_FREE(out); 530 545 return 1; /* needs_arg; */ 531 546 } 532 if (strnlen(value, 65) < 65) {547 if (strnlen(value, DOMAIN_SIZE+1) < DOMAIN_SIZE+1) { 533 548 got_domain = 1; 534 549 } else { 535 550 printf("domain name too long\n"); 551 SAFE_FREE(out); 536 552 return 1; 537 553 } … … 540 556 rc = open_cred_file(value); 541 557 if(rc) { 542 printf("error %d opening credential file %s\n",rc, value); 558 printf("error %d (%s) opening credential file %s\n", 559 rc, strerror(rc), value); 560 SAFE_FREE(out); 543 561 return 1; 544 562 } 545 563 } else { 546 564 printf("invalid credential file name specified\n"); 565 SAFE_FREE(out); 547 566 return 1; 548 567 } … … 583 602 if (!value || !*value) { 584 603 printf ("Option '%s' requires a numerical argument\n", data); 604 SAFE_FREE(out); 585 605 return 1; 586 606 } … … 597 617 if (!value || !*value) { 598 618 printf ("Option '%s' requires a numerical argument\n", data); 619 SAFE_FREE(out); 599 620 return 1; 600 621 } … … 630 651 *filesys_flags &= ~MS_NOEXEC; 631 652 } else if (strncmp(data, "guest", 5) == 0) { 632 got_password=1; 653 user_name = (char *)calloc(1, 1); 654 got_user = 1; 655 got_password = 1; 633 656 } else if (strncmp(data, "ro", 2) == 0) { 634 657 *filesys_flags |= MS_RDONLY; … … 718 741 } 719 742 720 free(*optionsp);743 SAFE_FREE(*optionsp); 721 744 *optionsp = out; 722 745 return 0; … … 746 769 if(number_of_commas == 0) 747 770 return; 748 if(number_of_commas > 64) {771 if(number_of_commas > MOUNT_PASSWD_SIZE) { 749 772 /* would otherwise overflow the mount options buffer */ 750 773 printf("\nInvalid password. Password contains too many commas.\n"); … … 765 788 new_pass_buf[len+number_of_commas] = 0; 766 789 767 free(*ppasswrd);790 SAFE_FREE(*ppasswrd); 768 791 *ppasswrd = new_pass_buf; 769 792 … … 860 883 861 884 /* Note that caller frees the returned buffer if necessary */ 862 static char * parse_server(char ** punc_name) 885 static struct addrinfo * 886 parse_server(char ** punc_name) 863 887 { 864 888 char * unc_name = *punc_name; 865 889 int length = strnlen(unc_name, MAX_UNC_LEN); 866 890 char * share; 867 char * ipaddress_string = NULL; 868 struct hostent * host_entry = NULL; 869 struct in_addr server_ipaddr; 891 struct addrinfo *addrlist; 892 int rc; 870 893 871 894 if(length > (MAX_UNC_LEN - 1)) { … … 873 896 return NULL; 874 897 } 875 if ( strncasecmp("cifs://",unc_name,7) == 0)876 return parse_cifs_url(unc_name+7);877 if (strncasecmp("smb://",unc_name,6) == 0) {878 return parse_cifs_url(unc_name+6);898 if ((strncasecmp("cifs://", unc_name, 7) == 0) || 899 (strncasecmp("smb://", unc_name, 6) == 0)) { 900 printf("\nMounting cifs URL not implemented yet. Attempt to mount %s\n", unc_name); 901 return NULL; 879 902 } 880 903 … … 896 919 } 897 920 *share = '/'; 898 str ncpy((*punc_name)+2,unc_name,length);899 free(unc_name);921 strlcpy((*punc_name)+2,unc_name,length+1); 922 SAFE_FREE(unc_name); 900 923 unc_name = *punc_name; 901 924 unc_name[length+2] = 0; … … 917 940 share += 1; 918 941 if(got_ip == 0) { 919 host_entry = gethostbyname(unc_name); 942 rc = getaddrinfo(unc_name, NULL, NULL, &addrlist); 943 if (rc != 0) { 944 printf("mount error: could not resolve address for %s: %s\n", 945 unc_name, gai_strerror(rc)); 946 addrlist = NULL; 947 } 920 948 } 921 949 *(share - 1) = '/'; /* put delimiter back */ … … 932 960 return NULL; 933 961 } 934 if(host_entry == NULL) { 935 printf("mount error: could not find target server. TCP name %s not found\n", unc_name); 936 return NULL; 937 } else { 938 /* BB should we pass an alternate version of the share name as Unicode */ 939 /* BB what about ipv6? BB */ 940 /* BB add retries with alternate servers in list */ 941 942 memcpy(&server_ipaddr.s_addr, host_entry->h_addr, 4); 943 944 ipaddress_string = inet_ntoa(server_ipaddr); 945 if(ipaddress_string == NULL) { 946 printf("mount error: could not get valid ip address for target server\n"); 947 return NULL; 948 } 949 return ipaddress_string; 950 } 962 /* BB should we pass an alternate version of the share name as Unicode */ 963 964 return addrlist; 951 965 } else { 952 966 /* BB add code to find DFS root (send null path on get DFS Referral to specified server here */ … … 1012 1026 char * orgoptions = NULL; 1013 1027 char * share_name = NULL; 1014 c har * ipaddr = NULL;1028 const char * ipaddr = NULL; 1015 1029 char * uuid = NULL; 1016 1030 char * mountpoint = NULL; 1017 1031 char * options = NULL; 1032 char * optionstail; 1018 1033 char * resolved_path = NULL; 1019 1034 char * temp; 1020 1035 char * dev_name; 1021 int rc ;1036 int rc = 0; 1022 1037 int rsize = 0; 1023 1038 int wsize = 0; … … 1028 1043 int orgoptlen = 0; 1029 1044 size_t options_size = 0; 1045 size_t current_len; 1030 1046 int retry = 0; /* set when we have to retry mount with uppercase */ 1047 struct addrinfo *addrhead = NULL, *addr; 1031 1048 struct stat statbuf; 1032 1049 struct utsname sysinfo; 1033 1050 struct mntent mountent; 1051 struct sockaddr_in *addr4; 1052 struct sockaddr_in6 *addr6; 1034 1053 FILE * pmntfile; 1035 1054 … … 1063 1082 mountpoint = argv[2]; 1064 1083 } else { 1084 if ((strcmp (argv[1], "--version") == 0) || 1085 ((strcmp (argv[1], "-V") == 0))) { 1086 printf ("mount.cifs version: %s.%s%s\n", 1087 MOUNT_CIFS_VERSION_MAJOR, 1088 MOUNT_CIFS_VERSION_MINOR, 1089 MOUNT_CIFS_VENDOR_SUFFIX); 1090 exit (0); 1091 } 1065 1092 mount_cifs_usage(); 1066 1093 exit(EX_USAGE); … … 1088 1115 exit(EX_USAGE); 1089 1116 case 'n': 1090 1091 1117 ++nomtab; 1118 break; 1092 1119 case 'b': 1093 1120 #ifdef MS_BIND … … 1123 1150 MOUNT_CIFS_VERSION_MINOR, 1124 1151 MOUNT_CIFS_VENDOR_SUFFIX); 1125 if(mountpassword) {1126 memset(mountpassword,0,64);1127 }1128 1152 exit (0); 1129 1153 case 'w': … … 1186 1210 case 'p': 1187 1211 if(mountpassword == NULL) 1188 mountpassword = (char *)calloc( 65,1);1212 mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); 1189 1213 if(mountpassword) { 1190 1214 got_password = 1; 1191 str ncpy(mountpassword,optarg,64);1215 strlcpy(mountpassword,optarg,MOUNT_PASSWD_SIZE+1); 1192 1216 } 1193 1217 break; … … 1196 1220 break; 1197 1221 case 't': 1222 break; 1223 case 'f': 1224 ++fakemnt; 1198 1225 break; 1199 1226 default: … … 1211 1238 if (getenv("PASSWD")) { 1212 1239 if(mountpassword == NULL) 1213 mountpassword = (char *)calloc( 65,1);1240 mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); 1214 1241 if(mountpassword) { 1215 str ncpy(mountpassword,getenv("PASSWD"),64);1242 strlcpy(mountpassword,getenv("PASSWD"),MOUNT_PASSWD_SIZE+1); 1216 1243 got_password = 1; 1217 1244 } … … 1226 1253 goto mount_exit; 1227 1254 } 1228 ipaddr = parse_server(&share_name);1229 if(( ipaddr== NULL) && (got_ip == 0)) {1255 addrhead = addr = parse_server(&share_name); 1256 if((addrhead == NULL) && (got_ip == 0)) { 1230 1257 printf("No ip address specified and hostname not found\n"); 1231 1258 rc = EX_USAGE; … … 1274 1301 1275 1302 if(got_user == 0) { 1276 user_name = getusername(); 1303 /* Note that the password will not be retrieved from the 1304 USER env variable (ie user%password form) as there is 1305 already a PASSWD environment varaible */ 1306 if (getenv("USER")) 1307 user_name = strdup(getenv("USER")); 1308 if (user_name == NULL) 1309 user_name = getusername(); 1277 1310 got_user = 1; 1278 1311 } 1279 1312 1280 1313 if(got_password == 0) { 1281 char *tmp_pass; 1282 tmp_pass = getpass("Password: "); /* BB obsolete sys call but 1283 no good replacement yet */ 1284 mountpassword = (char *)calloc(65,1); 1314 char *tmp_pass = getpass("Password: "); /* BB obsolete sys call but 1315 no good replacement yet. */ 1316 mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); 1285 1317 if (!tmp_pass || !mountpassword) { 1286 1318 printf("Password not entered, exiting\n"); 1287 1319 exit(EX_USAGE); 1288 1320 } 1289 strncpy(mountpassword, tmp_pass, 64); 1290 1321 strlcpy(mountpassword, tmp_pass, MOUNT_PASSWD_SIZE+1); 1291 1322 got_password = 1; 1292 1323 } 1293 1324 /* FIXME launch daemon (handles dfs name resolution and credential change) 1294 1325 remember to clear parms and overwrite password field before launching */ 1295 mount_retry:1296 1326 if(orgoptions) { 1297 1327 optlen = strlen(orgoptions); … … 1308 1338 if(user_name) 1309 1339 optlen += strlen(user_name) + 6; 1310 if(ipaddr) 1311 optlen += strlen(ipaddr) + 4; 1340 optlen += MAX_ADDRESS_LEN + 4; 1312 1341 if(mountpassword) 1313 1342 optlen += strlen(mountpassword) + 6; 1314 if(options) { 1315 free(options); 1316 options = NULL; 1317 } 1318 options_size = optlen + 10 + 64; 1343 mount_retry: 1344 SAFE_FREE(options); 1345 options_size = optlen + 10 + DOMAIN_SIZE; 1319 1346 options = (char *)malloc(options_size /* space for commas in password */ + 8 /* space for domain= , domain name itself was counted as part of the length username string above */); 1320 1347 … … 1324 1351 } 1325 1352 1326 options[0] = 0; 1327 strlcpy(options,"unc=",options_size); 1353 strlcpy(options, "unc=", options_size); 1328 1354 strlcat(options,share_name,options_size); 1329 1355 /* scan backwards and reverse direction of slash */ … … 1331 1357 if(temp > options + 6) 1332 1358 *temp = '\\'; 1333 if(ipaddr) {1334 strlcat(options,",ip=",options_size);1335 strlcat(options,ipaddr,options_size);1336 }1337 1338 1359 if(user_name) { 1339 1360 /* check for syntax like user=domain\user */ … … 1377 1398 replace_char(dev_name, '\\', '/', strlen(share_name)); 1378 1399 1379 if(mount(dev_name, mountpoint, "cifs", flags, options)) { 1380 /* remember to kill daemon on error */ 1400 if (!got_ip && addr) { 1401 strlcat(options, ",ip=", options_size); 1402 current_len = strnlen(options, options_size); 1403 optionstail = options + current_len; 1404 switch (addr->ai_addr->sa_family) { 1405 case AF_INET6: 1406 addr6 = (struct sockaddr_in6 *) addr->ai_addr; 1407 ipaddr = inet_ntop(AF_INET6, &addr6->sin6_addr, optionstail, 1408 options_size - current_len); 1409 break; 1410 case AF_INET: 1411 addr4 = (struct sockaddr_in *) addr->ai_addr; 1412 ipaddr = inet_ntop(AF_INET, &addr4->sin_addr, optionstail, 1413 options_size - current_len); 1414 break; 1415 } 1416 1417 /* if the address looks bogus, try the next one */ 1418 if (!ipaddr) { 1419 addr = addr->ai_next; 1420 if (addr) 1421 goto mount_retry; 1422 rc = EX_SYSERR; 1423 goto mount_exit; 1424 } 1425 } 1426 1427 if (!fakemnt && mount(dev_name, mountpoint, "cifs", flags, options)) { 1381 1428 switch (errno) { 1382 case 0: 1383 printf("mount failed but no error number set\n"); 1429 case ECONNREFUSED: 1430 case EHOSTUNREACH: 1431 if (addr) { 1432 addr = addr->ai_next; 1433 if (addr) 1434 goto mount_retry; 1435 } 1384 1436 break; 1385 1437 case ENODEV: … … 1396 1448 } 1397 1449 } 1398 default: 1399 printf("mount error %d = %s\n",errno,strerror(errno)); 1400 } 1450 } 1451 printf("mount error(%d): %s\n", errno, strerror(errno)); 1401 1452 printf("Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)\n"); 1402 1453 rc = EX_FAIL; 1403 } else { 1404 atexit(unlock_mtab); 1405 rc = lock_mtab(); 1406 if (rc) { 1407 printf("cannot lock mtab"); 1408 goto mount_exit; 1409 } 1410 pmntfile = setmntent(MOUNTED, "a+"); 1411 if (!pmntfile) { 1412 printf("could not update mount table\n"); 1413 unlock_mtab(); 1414 rc = EX_FILEIO; 1415 goto mount_exit; 1416 } 1417 mountent.mnt_fsname = dev_name; 1418 mountent.mnt_dir = mountpoint; 1419 mountent.mnt_type = CONST_DISCARD(char *,"cifs"); 1420 mountent.mnt_opts = (char *)malloc(220); 1421 if(mountent.mnt_opts) { 1422 char * mount_user = getusername(); 1423 memset(mountent.mnt_opts,0,200); 1424 if(flags & MS_RDONLY) 1425 strlcat(mountent.mnt_opts,"ro",220); 1426 else 1427 strlcat(mountent.mnt_opts,"rw",220); 1428 if(flags & MS_MANDLOCK) 1429 strlcat(mountent.mnt_opts,",mand",220); 1430 if(flags & MS_NOEXEC) 1431 strlcat(mountent.mnt_opts,",noexec",220); 1432 if(flags & MS_NOSUID) 1433 strlcat(mountent.mnt_opts,",nosuid",220); 1434 if(flags & MS_NODEV) 1435 strlcat(mountent.mnt_opts,",nodev",220); 1436 if(flags & MS_SYNCHRONOUS) 1437 strlcat(mountent.mnt_opts,",sync",220); 1438 if(mount_user) { 1439 if(getuid() != 0) { 1440 strlcat(mountent.mnt_opts, 1441 ",user=", 220); 1442 strlcat(mountent.mnt_opts, 1443 mount_user, 220); 1444 } 1445 } 1446 } 1447 mountent.mnt_freq = 0; 1448 mountent.mnt_passno = 0; 1449 rc = addmntent(pmntfile,&mountent); 1450 endmntent(pmntfile); 1454 goto mount_exit; 1455 } 1456 1457 if (nomtab) 1458 goto mount_exit; 1459 atexit(unlock_mtab); 1460 rc = lock_mtab(); 1461 if (rc) { 1462 printf("cannot lock mtab"); 1463 goto mount_exit; 1464 } 1465 pmntfile = setmntent(MOUNTED, "a+"); 1466 if (!pmntfile) { 1467 printf("could not update mount table\n"); 1451 1468 unlock_mtab(); 1452 if(mountent.mnt_opts) { 1453 free(mountent.mnt_opts); 1454 mountent.mnt_opts = NULL; 1455 } 1456 if (rc) 1457 rc = EX_FILEIO; 1458 } 1469 rc = EX_FILEIO; 1470 goto mount_exit; 1471 } 1472 mountent.mnt_fsname = dev_name; 1473 mountent.mnt_dir = mountpoint; 1474 mountent.mnt_type = CONST_DISCARD(char *,"cifs"); 1475 mountent.mnt_opts = (char *)malloc(220); 1476 if(mountent.mnt_opts) { 1477 char * mount_user = getusername(); 1478 memset(mountent.mnt_opts,0,200); 1479 if(flags & MS_RDONLY) 1480 strlcat(mountent.mnt_opts,"ro",220); 1481 else 1482 strlcat(mountent.mnt_opts,"rw",220); 1483 if(flags & MS_MANDLOCK) 1484 strlcat(mountent.mnt_opts,",mand",220); 1485 if(flags & MS_NOEXEC) 1486 strlcat(mountent.mnt_opts,",noexec",220); 1487 if(flags & MS_NOSUID) 1488 strlcat(mountent.mnt_opts,",nosuid",220); 1489 if(flags & MS_NODEV) 1490 strlcat(mountent.mnt_opts,",nodev",220); 1491 if(flags & MS_SYNCHRONOUS) 1492 strlcat(mountent.mnt_opts,",sync",220); 1493 if(mount_user) { 1494 if(getuid() != 0) { 1495 strlcat(mountent.mnt_opts, 1496 ",user=", 220); 1497 strlcat(mountent.mnt_opts, 1498 mount_user, 220); 1499 } 1500 } 1501 } 1502 mountent.mnt_freq = 0; 1503 mountent.mnt_passno = 0; 1504 rc = addmntent(pmntfile,&mountent); 1505 endmntent(pmntfile); 1506 unlock_mtab(); 1507 SAFE_FREE(mountent.mnt_opts); 1508 if (rc) 1509 rc = EX_FILEIO; 1459 1510 mount_exit: 1460 1511 if(mountpassword) { 1461 1512 int len = strlen(mountpassword); 1462 1513 memset(mountpassword,0,len); 1463 free(mountpassword); 1464 mountpassword = NULL; 1465 } 1466 1467 if(options) { 1468 memset(options,0,optlen); 1469 free(options); 1470 options = NULL; 1471 } 1472 1473 if(orgoptions) { 1474 memset(orgoptions,0,orgoptlen); 1475 free(orgoptions); 1476 orgoptions = NULL; 1477 } 1478 if(resolved_path) { 1479 free(resolved_path); 1480 resolved_path = NULL; 1481 } 1482 1483 free(share_name); 1514 SAFE_FREE(mountpassword); 1515 } 1516 1517 if (addrhead) 1518 freeaddrinfo(addrhead); 1519 SAFE_FREE(options); 1520 SAFE_FREE(orgoptions); 1521 SAFE_FREE(resolved_path); 1522 SAFE_FREE(share_name); 1484 1523 exit(rc); 1485 1524 } -
branches/samba-3.0/source/client/umount.cifs.c
r165 r312 35 35 #include <string.h> 36 36 #include <mntent.h> 37 #include <limits.h> 37 38 #include "mount.h" 38 39 … … 233 234 } 234 235 236 /* Make a canonical pathname from PATH. Returns a freshly malloced string. 237 It is up the *caller* to ensure that the PATH is sensible. i.e. 238 canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.'' 239 is not a legal pathname for ``/dev/fd0'' Anything we cannot parse 240 we return unmodified. */ 241 static char * 242 canonicalize(char *path) 243 { 244 char *canonical = malloc (PATH_MAX + 1); 245 246 if (!canonical) { 247 fprintf(stderr, "Error! Not enough memory!\n"); 248 return NULL; 249 } 250 251 if (strlen(path) > PATH_MAX) { 252 fprintf(stderr, "Mount point string too long\n"); 253 return NULL; 254 } 255 256 if (path == NULL) 257 return NULL; 258 259 if (realpath (path, canonical)) 260 return canonical; 261 262 strncpy (canonical, path, PATH_MAX); 263 canonical[PATH_MAX] = '\0'; 264 return canonical; 265 } 266 235 267 int main(int argc, char ** argv) 236 268 { … … 306 338 argc -= optind; 307 339 308 mountpoint = argv[0];340 mountpoint = canonicalize(argv[0]); 309 341 310 342 if((argc < 1) || (argv[0] == NULL)) { -
branches/samba-3.0/source/configure
r286 r312 14036 14036 14037 14037 14038 14039 14040 14041 for ac_header in netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h 14038 for ac_header in netinet/in_systm.h 14039 do 14040 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 14041 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 14042 { echo "$as_me:$LINENO: checking for $ac_header" >&5 14043 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 14044 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 14045 echo $ECHO_N "(cached) $ECHO_C" >&6 14046 fi 14047 ac_res=`eval echo '${'$as_ac_Header'}'` 14048 { echo "$as_me:$LINENO: result: $ac_res" >&5 14049 echo "${ECHO_T}$ac_res" >&6; } 14050 else 14051 # Is the header compilable? 14052 { echo "$as_me:$LINENO: checking $ac_header usability" >&5 14053 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } 14054 cat >conftest.$ac_ext <<_ACEOF 14055 /* confdefs.h. */ 14056 _ACEOF 14057 cat confdefs.h >>conftest.$ac_ext 14058 cat >>conftest.$ac_ext <<_ACEOF 14059 /* end confdefs.h. */ 14060 $ac_includes_default 14061 #include <$ac_header> 14062 _ACEOF 14063 rm -f conftest.$ac_objext 14064 if { (ac_try="$ac_compile" 14065 case "(($ac_try" in 14066 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 14067 *) ac_try_echo=$ac_try;; 14068 esac 14069 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 14070 (eval "$ac_compile") 2>conftest.er1 14071 ac_status=$? 14072 grep -v '^ *+' conftest.er1 >conftest.err 14073 rm -f conftest.er1 14074 cat conftest.err >&5 14075 echo "$as_me:$LINENO: \$? = $ac_status" >&5 14076 (exit $ac_status); } && { 14077 test -z "$ac_c_werror_flag" || 14078 test ! -s conftest.err 14079 } && test -s conftest.$ac_objext; then 14080 ac_header_compiler=yes 14081 else 14082 echo "$as_me: failed program was:" >&5 14083 sed 's/^/| /' conftest.$ac_ext >&5 14084 14085 ac_header_compiler=no 14086 fi 14087 14088 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 14089 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 14090 echo "${ECHO_T}$ac_header_compiler" >&6; } 14091 14092 # Is the header present? 14093 { echo "$as_me:$LINENO: checking $ac_header presence" >&5 14094 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } 14095 cat >conftest.$ac_ext <<_ACEOF 14096 /* confdefs.h. */ 14097 _ACEOF 14098 cat confdefs.h >>conftest.$ac_ext 14099 cat >>conftest.$ac_ext <<_ACEOF 14100 /* end confdefs.h. */ 14101 #include <$ac_header> 14102 _ACEOF 14103 if { (ac_try="$ac_cpp conftest.$ac_ext" 14104 case "(($ac_try" in 14105 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 14106 *) ac_try_echo=$ac_try;; 14107 esac 14108 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 14109 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 14110 ac_status=$? 14111 grep -v '^ *+' conftest.er1 >conftest.err 14112 rm -f conftest.er1 14113 cat conftest.err >&5 14114 echo "$as_me:$LINENO: \$? = $ac_status" >&5 14115 (exit $ac_status); } >/dev/null && { 14116 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || 14117 test ! -s conftest.err 14118 }; then 14119 ac_header_preproc=yes 14120 else 14121 echo "$as_me: failed program was:" >&5 14122 sed 's/^/| /' conftest.$ac_ext >&5 14123 14124 ac_header_preproc=no 14125 fi 14126 14127 rm -f conftest.err conftest.$ac_ext 14128 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 14129 echo "${ECHO_T}$ac_header_preproc" >&6; } 14130 14131 # So? What about this header? 14132 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 14133 yes:no: ) 14134 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 14135 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} 14136 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 14137 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} 14138 ac_header_preproc=yes 14139 ;; 14140 no:yes:* ) 14141 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 14142 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} 14143 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 14144 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 14145 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 14146 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} 14147 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 14148 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} 14149 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 14150 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} 14151 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 14152 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} 14153 14154 ;; 14155 esac 14156 { echo "$as_me:$LINENO: checking for $ac_header" >&5 14157 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 14158 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 14159 echo $ECHO_N "(cached) $ECHO_C" >&6 14160 else 14161 eval "$as_ac_Header=\$ac_header_preproc" 14162 fi 14163 ac_res=`eval echo '${'$as_ac_Header'}'` 14164 { echo "$as_me:$LINENO: result: $ac_res" >&5 14165 echo "${ECHO_T}$ac_res" >&6; } 14166 14167 fi 14168 if test `eval echo '${'$as_ac_Header'}'` = yes; then 14169 cat >>confdefs.h <<_ACEOF 14170 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 14171 _ACEOF 14172 14173 fi 14174 14175 done 14176 14177 14178 for ac_header in netinet/ip.h 14179 do 14180 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 14181 { echo "$as_me:$LINENO: checking for $ac_header" >&5 14182 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 14183 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 14184 echo $ECHO_N "(cached) $ECHO_C" >&6 14185 else 14186 cat >conftest.$ac_ext <<_ACEOF 14187 /* confdefs.h. */ 14188 _ACEOF 14189 cat confdefs.h >>conftest.$ac_ext 14190 cat >>conftest.$ac_ext <<_ACEOF 14191 /* end confdefs.h. */ 14192 #ifdef HAVE_NETINET_IN_H 14193 #include <netinet/in.h> 14194 #endif 14195 #ifdef HAVE_NETINET_IN_SYSTM_H 14196 #include <netinet/in_systm.h> 14197 #endif 14198 14199 #include <$ac_header> 14200 _ACEOF 14201 rm -f conftest.$ac_objext 14202 if { (ac_try="$ac_compile" 14203 case "(($ac_try" in 14204 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 14205 *) ac_try_echo=$ac_try;; 14206 esac 14207 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 14208 (eval "$ac_compile") 2>conftest.er1 14209 ac_status=$? 14210 grep -v '^ *+' conftest.er1 >conftest.err 14211 rm -f conftest.er1 14212 cat conftest.err >&5 14213 echo "$as_me:$LINENO: \$? = $ac_status" >&5 14214 (exit $ac_status); } && { 14215 test -z "$ac_c_werror_flag" || 14216 test ! -s conftest.err 14217 } && test -s conftest.$ac_objext; then 14218 eval "$as_ac_Header=yes" 14219 else 14220 echo "$as_me: failed program was:" >&5 14221 sed 's/^/| /' conftest.$ac_ext >&5 14222 14223 eval "$as_ac_Header=no" 14224 fi 14225 14226 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 14227 fi 14228 ac_res=`eval echo '${'$as_ac_Header'}'` 14229 { echo "$as_me:$LINENO: result: $ac_res" >&5 14230 echo "${ECHO_T}$ac_res" >&6; } 14231 if test `eval echo '${'$as_ac_Header'}'` = yes; then 14232 cat >>confdefs.h <<_ACEOF 14233 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 14234 _ACEOF 14235 14236 fi 14237 14238 done 14239 14240 14241 14242 for ac_header in netinet/tcp.h netinet/in_ip.h 14042 14243 do 14043 14244 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -
branches/samba-3.0/source/configure.os2
r23 r312 5 5 AR="emxomfar" \ 6 6 LIBS="-lsocket -lsyslog" \ 7 ./configure --prefix=/samba \7 ./configure --prefix=/samba --with-acl-support \ 8 8 --enable-static --disable-shared \ 9 9 --disable-ldap --disable-cups 2>&1 | tee configure.log -
branches/samba-3.0/source/include/includes.h
r140 r312 209 209 #endif 210 210 211 #if HAVE_GSSAPI_H 212 #include <gssapi.h> 213 #elif HAVE_GSSAPI_GSSAPI_H 211 #if HAVE_GSSAPI_GSSAPI_H 214 212 #include <gssapi/gssapi.h> 215 213 #elif HAVE_GSSAPI_GSSAPI_GENERIC_H 216 214 #include <gssapi/gssapi_generic.h> 215 #elif HAVE_GSSAPI_H 216 #include <gssapi.h> 217 217 #endif 218 218 -
branches/samba-3.0/source/include/version.h
r286 r312 2 2 #define SAMBA_VERSION_MAJOR 3 3 3 #define SAMBA_VERSION_MINOR 0 4 #define SAMBA_VERSION_RELEASE 35 5 #define SAMBA_VERSION_OFFICIAL_STRING "3.0.35" 4 #define SAMBA_VERSION_RELEASE 36 5 #define SAMBA_VERSION_OFFICIAL_STRING "3.0.36" 6 #define SAMBA_VERSION_VENDOR_SUFFIX "eCS 1.0.2" 6 7 #define SAMBA_VERSION_STRING samba_version_string() -
branches/samba-3.0/source/lib/replace/libreplace.m4
r124 r312 98 98 AC_CHECK_HEADERS(stdarg.h vararg.h) 99 99 AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) 100 AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) 100 AC_CHECK_HEADERS(netinet/in_systm.h) 101 AC_CHECK_HEADERS([netinet/ip.h], [], [], [#ifdef HAVE_NETINET_IN_H 102 #include <netinet/in.h> 103 #endif 104 #ifdef HAVE_NETINET_IN_SYSTM_H 105 #include <netinet/in_systm.h> 106 #endif]) 107 AC_CHECK_HEADERS(netinet/tcp.h netinet/in_ip.h) 101 108 AC_CHECK_HEADERS(sys/sockio.h sys/un.h) 102 109 AC_CHECK_HEADERS(stropts.h) -
branches/samba-3.0/source/libaddns/dns.h
r39 r312 77 77 #endif 78 78 79 #if HAVE_GSSAPI_H 80 #include <gssapi.h> 81 #elif HAVE_GSSAPI_GSSAPI_H 79 #if HAVE_GSSAPI_GSSAPI_H 82 80 #include <gssapi/gssapi.h> 83 81 #elif HAVE_GSSAPI_GSSAPI_GENERIC_H 84 82 #include <gssapi/gssapi_generic.h> 83 #elif HAVE_GSSAPI_H 84 #include <gssapi.h> 85 85 #endif 86 86 -
branches/samba-3.0/source/libads/cldap.c
r22 r312 61 61 followed_ptr = 1; 62 62 } 63 len = ((ptr[0] & 0x3f) << 8) | ptr[1];63 len = ((ptr[0] & 0x3f) << 8) | (uint8) ptr[1]; 64 64 ptr = data + len; 65 65 } else if (*ptr) { -
branches/samba-3.0/source/libads/ldap.c
r165 r312 113 113 return LDAP_TIMELIMIT_EXCEEDED; 114 114 115 116 /* 117 * A bug in OpenLDAP means ldap_search_ext_s can return 118 * LDAP_SUCCESS but with a NULL res pointer. Cope with 119 * this. See bug #6279 for details. JRA. 120 */ 121 122 if (*res == NULL) { 123 return LDAP_TIMELIMIT_EXCEEDED; 124 } 125 115 126 return result; 116 127 } … … 276 287 got_realm = True; 277 288 289 again: 290 278 291 /* we need to try once with the realm name and fallback to the 279 292 netbios domain name if we fail (if netbios has not been disabled */ … … 326 339 327 340 sitename = sitename_fetch(realm); 328 329 again:330 341 331 342 DEBUG(6,("ads_find_dc: (cldap) looking for %s '%s'\n", -
branches/samba-3.0/source/libsmb/namequery.c
r165 r312 1226 1226 1227 1227 DEBUG(10, ("internal_resolve_name: looking up %s#%x (sitename %s)\n", 1228 name, name_type, sitename ? sitename : NULL));1228 name, name_type, sitename ? sitename : "(null)")); 1229 1229 1230 1230 if (allzeros || allones || is_address) { -
branches/samba-3.0/source/modules/nfs4_acls.c
r39 r312 588 588 589 589 SMB_STRUCT_STAT sbuf; 590 BOOL need_chown= False;590 BOOL set_acl_as_root = False; 591 591 uid_t newUID = (uid_t)-1; 592 592 gid_t newGID = (gid_t)-1; 593 int saved_errno; 593 594 594 595 DEBUG(10, ("smb_set_nt_acl_nfs4 invoked for %s\n", fsp->fsp_name)); … … 618 619 if (((newUID != (uid_t)-1) && (sbuf.st_uid != newUID)) || 619 620 ((newGID != (gid_t)-1) && (sbuf.st_gid != newGID))) { 620 need_chown = True; 621 } 622 if (need_chown) { 623 if ((newUID == (uid_t)-1 || newUID == current_user.ut.uid)) { 624 if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { 625 DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n", 626 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, strerror(errno) )); 627 return False; 628 } 629 DEBUG(10,("chown %s, %u, %u succeeded.\n", 630 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 631 if (smbacl4_GetFileOwner(fsp, &sbuf)) 632 return False; 633 need_chown = False; 634 } else { /* chown is needed, but _after_ changing acl */ 635 sbuf.st_uid = newUID; /* OWNER@ in case of e_special */ 636 sbuf.st_gid = newGID; /* GROUP@ in case of e_special */ 637 } 638 } 639 } 640 641 if ((security_info_sent & DACL_SECURITY_INFORMATION)!=0 && psd->dacl!=NULL) 642 { 643 acl = smbacl4_win2nfs4(psd->dacl, ¶ms, sbuf.st_uid, sbuf.st_gid); 644 if (!acl) 645 return False; 646 647 smbacl4_dump_nfs4acl(10, acl); 648 649 result = set_nfs4_native(fsp, acl); 650 if (result!=True) 651 { 652 DEBUG(10, ("set_nfs4_native failed with %s\n", strerror(errno))); 653 return False; 654 } 655 } else 621 if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { 622 DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n", 623 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, strerror(errno) )); 624 return False; 625 } 626 DEBUG(10,("chown %s, %u, %u succeeded.\n", 627 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 628 if (smbacl4_GetFileOwner(fsp, &sbuf)) 629 return False; 630 /* If we successfully chowned, we know we must 631 * be able to set the acl, so do it as root. 632 */ 633 set_acl_as_root = True; 634 } 635 } 636 637 if (!(security_info_sent & DACL_SECURITY_INFORMATION) || psd->dacl ==NULL) { 656 638 DEBUG(10, ("no dacl found; security_info_sent = 0x%x\n", security_info_sent)); 657 658 /* Any chown pending? */ 659 if (need_chown) { 660 DEBUG(3,("chown#2 %s. uid = %u, gid = %u.\n", 661 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 662 if (try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { 663 DEBUG(2,("chown#2 %s, %u, %u failed. Error = %s.\n", 664 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, 665 strerror(errno))); 666 return False; 667 } 668 DEBUG(10,("chown#2 %s, %u, %u succeeded.\n", 669 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 639 return True; 640 } 641 acl = smbacl4_win2nfs4(psd->dacl, ¶ms, sbuf.st_uid, sbuf.st_gid); 642 if (!acl) 643 return False; 644 645 smbacl4_dump_nfs4acl(10, acl); 646 647 if (set_acl_as_root) { 648 become_root(); 649 } 650 result = set_nfs4_native(fsp, acl); 651 saved_errno = errno; 652 if (set_acl_as_root) { 653 unbecome_root(); 654 } 655 if (result!=True) { 656 errno = saved_errno; 657 DEBUG(10, ("set_nfs4_native failed with %s\n", strerror(errno))); 658 return False; 670 659 } 671 660 -
branches/samba-3.0/source/modules/vfs_default.c
r124 r312 636 636 times.actime = convert_timespec_to_time_t(ts[0]); 637 637 times.modtime = convert_timespec_to_time_t(ts[1]); 638 result = utime(path, times);638 result = utime(path, ×); 639 639 } 640 640 #else -
branches/samba-3.0/source/nsswitch/winbindd_passdb.c
r165 r312 591 591 continue; 592 592 } 593 if (!((*names)[ i] = talloc_strdup((*names),593 if (!((*names)[num_mapped] = talloc_strdup((*names), 594 594 lsa_names[i].name))) { 595 595 TALLOC_FREE(tmp_ctx); … … 597 597 } 598 598 599 (*name_types)[ i] = lsa_names[i].type;599 (*name_types)[num_mapped] = lsa_names[i].type; 600 600 601 601 num_mapped += 1; -
branches/samba-3.0/source/nsswitch/wins.c
r1 r312 25 25 26 26 #include <ns_daemon.h> 27 #endif 28 29 #if HAVE_PTHREAD_H 30 #include <pthread.h> 31 #endif 32 33 #if HAVE_PTHREAD 34 static pthread_mutex_t wins_nss_mutex = PTHREAD_MUTEX_INITIALIZER; 27 35 #endif 28 36 … … 298 306 char *buffer, size_t buflen, int *h_errnop) 299 307 { 308 NSS_STATUS nss_status = NSS_STATUS_SUCCESS; 300 309 struct in_addr *ip_list; 301 310 int i, count; … … 303 312 size_t namelen; 304 313 314 #if HAVE_PTHREAD 315 pthread_mutex_lock(&wins_nss_mutex); 316 #endif 317 305 318 memset(he, '\0', sizeof(*he)); 306 319 fstrcpy(name, hostname); … … 310 323 ip_list = lookup_byname_backend(name, &count); 311 324 312 if (!ip_list) 313 return NSS_STATUS_NOTFOUND; 325 if (!ip_list) { 326 nss_status = NSS_STATUS_NOTFOUND; 327 goto out; 328 } 314 329 315 330 /* Copy h_name */ … … 317 332 namelen = strlen(name) + 1; 318 333 319 if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) 320 return NSS_STATUS_TRYAGAIN; 334 if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) { 335 nss_status = NSS_STATUS_TRYAGAIN; 336 goto out; 337 } 321 338 322 339 memcpy(he->h_name, name, namelen); … … 327 344 i = sizeof(char*) - i; 328 345 329 if (get_static(&buffer, &buflen, i) == NULL) 330 return NSS_STATUS_TRYAGAIN; 346 if (get_static(&buffer, &buflen, i) == NULL) { 347 nss_status = NSS_STATUS_TRYAGAIN; 348 goto out; 349 } 331 350 332 351 if ((he->h_addr_list = (char **)get_static( 333 &buffer, &buflen, (count + 1) * sizeof(char *))) == NULL) 334 return NSS_STATUS_TRYAGAIN; 352 &buffer, &buflen, (count + 1) * sizeof(char *))) == NULL) { 353 nss_status = NSS_STATUS_TRYAGAIN; 354 goto out; 355 } 335 356 336 357 for (i = 0; i < count; i++) { 337 358 if ((he->h_addr_list[i] = get_static(&buffer, &buflen, 338 INADDRSZ)) == NULL) 339 return NSS_STATUS_TRYAGAIN; 359 INADDRSZ)) == NULL) { 360 nss_status = NSS_STATUS_TRYAGAIN; 361 goto out; 362 } 340 363 memcpy(he->h_addr_list[i], &ip_list[i], INADDRSZ); 341 364 } … … 356 379 i = sizeof(char*) - i; 357 380 358 if (get_static(&buffer, &buflen, i) == NULL) 359 return NSS_STATUS_TRYAGAIN; 381 if (get_static(&buffer, &buflen, i) == NULL) { 382 nss_status = NSS_STATUS_TRYAGAIN; 383 goto out; 384 } 360 385 361 386 if ((he->h_aliases = (char **)get_static( 362 &buffer, &buflen, sizeof(char *))) == NULL) 363 return NSS_STATUS_TRYAGAIN; 387 &buffer, &buflen, sizeof(char *))) == NULL) { 388 nss_status = NSS_STATUS_TRYAGAIN; 389 goto out; 390 } 364 391 365 392 he->h_aliases[0] = NULL; 366 393 367 return NSS_STATUS_SUCCESS; 394 nss_status = NSS_STATUS_SUCCESS; 395 396 out: 397 398 #if HAVE_PTHREAD 399 pthread_mutex_unlock(&wins_nss_mutex); 400 #endif 401 return nss_status; 368 402 } 369 403 … … 373 407 char *buffer, size_t buflen, int *h_errnop) 374 408 { 409 NSS_STATUS nss_status; 410 411 #if HAVE_PTHREAD 412 pthread_mutex_lock(&wins_nss_mutex); 413 #endif 414 375 415 if(af!=AF_INET) { 376 416 *h_errnop = NO_DATA; 377 return NSS_STATUS_UNAVAIL; 378 } 379 380 return _nss_wins_gethostbyname_r( 381 name, he, buffer, buflen, h_errnop); 382 } 383 #endif 417 nss_status = NSS_STATUS_UNAVAIL; 418 } else { 419 nss_status = _nss_wins_gethostbyname_r( 420 name, he, buffer, buflen, h_errnop); 421 } 422 #if HAVE_PTHREAD 423 pthread_mutex_unlock(&wins_nss_mutex); 424 #endif 425 return nss_status; 426 } 427 #endif -
branches/samba-3.0/source/param/loadparm.c
r307 r312 151 151 char *szPanicAction; 152 152 char *szAddUserScript; 153 153 char *szRenameUserScript; 154 154 char *szDelUserScript; 155 155 char *szAddGroupScript; … … 188 188 char *szChangeShareCommand; 189 189 char *szDeleteShareCommand; 190 190 char **szEventLogs; 191 191 char *szGuestaccount; 192 192 char *szManglingMethod; … … 472 472 False, /* not autoloaded */ 473 473 0, /* not a usershare */ 474 (time_t)0, 474 (time_t)0, /* No last mod time */ 475 475 NULL, /* szService */ 476 476 NULL, /* szPath */ … … 513 513 NULL, /* fstype */ 514 514 NULL, /* vfs objects */ 515 NULL, 515 NULL, /* szMSDfsProxy */ 516 516 NULL, /* szAioWriteBehind */ 517 517 NULL, /* szDfree */ … … 533 533 2, /* iOplockContentionLimit */ 534 534 0, /* iCSCPolicy */ 535 1024, 535 1024, /* iBlock_size */ 536 536 0, /* iDfreeCacheTime */ 537 537 False, /* bPreexecClose */ … … 588 588 False, /* bForcePrintername */ 589 589 True, /* bNTAclSupport */ 590 False, 590 False, /* bForceUnknownAclUser */ 591 591 False, /* bUseSendfile */ 592 592 False, /* bProfileAcls */ … … 821 821 {MAP_TO_GUEST_ON_BAD_USER, "Bad User"}, 822 822 {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"}, 823 823 {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"}, 824 824 {-1, NULL} 825 825 }; … … 834 834 * Any parameter that does NOT have FLAG_ADVANCED will not disply at all 835 835 * Set FLAG_SHARE and FLAG_PRINT to specifically display parameters in 836 * 836 * respective views. 837 837 * 838 838 * NOTE2: Handling of duplicated (synonym) paramters: … … 1122 1122 1123 1123 {"add user script", P_STRING, P_GLOBAL, &Globals.szAddUserScript, NULL, NULL, FLAG_ADVANCED}, 1124 1124 {"rename user script", P_STRING, P_GLOBAL, &Globals.szRenameUserScript, NULL, NULL, FLAG_ADVANCED}, 1125 1125 {"delete user script", P_STRING, P_GLOBAL, &Globals.szDelUserScript, NULL, NULL, FLAG_ADVANCED}, 1126 1126 {"add group script", P_STRING, P_GLOBAL, &Globals.szAddGroupScript, NULL, NULL, FLAG_ADVANCED}, … … 1418 1418 pstring s; 1419 1419 1420 1421 1422 1423 1424 1420 /* If requested to initialize only once and we've already done it... */ 1421 if (first_time_only && done_init) { 1422 /* ... then we have nothing more to do */ 1423 return; 1424 } 1425 1425 1426 1426 if (!done_init) { … … 1462 1462 1463 1463 #if defined (__OS2__) 1464 1465 1466 1467 1468 1469 1470 1471 1472 1464 /* search the system codepage and set OS2CodePageStr */ 1465 unsigned long _System DosQueryCp (unsigned long ulLength, unsigned long *pCodePageList, unsigned long *pDataLength); 1466 pstring OS2CodePageStr; 1467 unsigned long OS2CodePage[3]; 1468 unsigned long OS2CodePageLen; 1469 if ( DosQueryCp( sizeof(OS2CodePage), OS2CodePage, &OS2CodePageLen ) ) 1470 slprintf(OS2CodePageStr, sizeof(OS2CodePageStr) -1, "SYSTEM"); 1471 else 1472 slprintf(OS2CodePageStr, sizeof(OS2CodePageStr) -1, "IBM-%u", OS2CodePage[0]); 1473 1473 #endif 1474 1474 … … 1492 1492 characters - default to system codepage */ 1493 1493 string_set(&Globals.display_charset, OS2CodePageStr); 1494 #endif 1494 #endif 1495 1495 1496 1496 #else … … 2238 2238 BOOL global_section = False; 2239 2239 char* param_key; 2240 2240 param_opt_struct *data; 2241 2241 2242 2242 if (snum >= iNumServices) return NULL; … … 2268 2268 data = Globals.param_opt; 2269 2269 while (data) { 2270 2271 2270 if (strcmp(data->key, param_key) == 0) { 2271 string_free(¶m_key); 2272 2272 return data; 2273 2273 } … … 2486 2486 { 2487 2487 int i; 2488 2488 param_opt_struct *data, *pdata; 2489 2489 if (!pservice) 2490 2490 return; … … 2670 2670 DEBUG(10,("hash_a_service: creating tdb servicehash\n")); 2671 2671 ServiceHash = tdb_open("servicehash", 1031, TDB_INTERNAL, 2672 2672 (O_RDWR|O_CREAT), 0600); 2673 2673 if ( !ServiceHash ) { 2674 2674 DEBUG(0,("hash_a_service: open tdb servicehash failed!\n")); … … 2683 2683 return False; 2684 2684 2685 2685 tdb_store_int32(ServiceHash, canon_name, idx); 2686 2686 2687 2687 return True; -
branches/samba-3.0/source/rpc_server/srv_netlog_nt.c
r134 r312 432 432 DOM_CHAL srv_chal_out; 433 433 434 /* According to Microsoft (see bugid #6099) 435 * Windows 7 looks at the negotiate_flags 436 * returned in this structure *even if the 437 * call fails with access denied ! So in order 438 * to allow Win7 to connect to a Samba NT style 439 * PDC we set the flags before we know if it's 440 * an error or not. 441 */ 442 443 srv_flgs.neg_flags = 0x000001ff; 444 445 if (lp_server_schannel() != False) { 446 srv_flgs.neg_flags |= NETLOGON_NEG_SCHANNEL; 447 } 448 449 /* set up the initial LSA AUTH 2 response */ 450 ZERO_STRUCT(srv_chal_out); 451 init_net_r_auth_2(r_u, &srv_chal_out, &srv_flgs, NT_STATUS_OK); 452 434 453 rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), 435 454 q_u->clnt_id.uni_acct_name.uni_str_len*2,0); … … 480 499 } 481 500 482 srv_flgs.neg_flags = 0x000001ff; 483 484 if (lp_server_schannel() != False) { 485 srv_flgs.neg_flags |= NETLOGON_NEG_SCHANNEL; 486 } 487 488 /* set up the LSA AUTH 2 response */ 501 /* set up the real LSA AUTH 2 response */ 489 502 init_net_r_auth_2(r_u, &srv_chal_out, &srv_flgs, NT_STATUS_OK); 490 503 -
branches/samba-3.0/source/rpc_server/srv_pipe.c
r1 r312 2063 2063 auth_len = p->hdr.auth_len; 2064 2064 2065 if (auth_len != RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) { 2065 if (auth_len < RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN || 2066 auth_len > RPC_HEADER_LEN + 2067 RPC_HDR_REQ_LEN + 2068 RPC_HDR_AUTH_LEN + 2069 auth_len) { 2066 2070 DEBUG(0,("Incorrect auth_len %u.\n", (unsigned int)auth_len )); 2067 2071 return False; -
branches/samba-3.0/source/script/installman.sh
r1 r312 21 21 # Get the configured feature set 22 22 test -f "${SRCDIR}/config.log" && \ 23 eval `grep "^[[:alnum:] ]*=.*" "${SRCDIR}/config.log"`23 eval `grep "^[[:alnum:]_]*=.*" "${SRCDIR}/config.log"` 24 24 25 25 for lang in $langs; do … … 49 49 # Check if this man page if required by the configured feature set 50 50 case "${MP_BASENAME}" in 51 cifs.upcall.8) test -z "${CIFSUPCALL_PROGS}" && continue ;; 51 52 smbsh.1) test -z "${SMBWRAPPER}" && continue ;; 52 53 smbmnt.8|smbmount.8|smbumount.8) test -z "${SMBMOUNT_PROGS}" && continue ;; -
branches/samba-3.0/source/smbd/lanman.c
r105 r312 1138 1138 continue; 1139 1139 } 1140 if (!next_token(&ptr,s->comment, NULL, sizeof(s->comment))) { 1140 if (!next_token(&ptr,s->comment, NULL, 1141 MIN(sizeof(s->comment), 1142 MAX_SERVER_STRING_LENGTH))) { 1141 1143 continue; 1142 1144 } -
branches/samba-3.0/source/smbd/posix_acls.c
r286 r312 3098 3098 } 3099 3099 3100 /* only allow chown to the current user. This is more secure, 3101 and also copes with the case where the SID in a take ownership ACL is 3102 a local SID on the users workstation 3103 */ 3104 if (uid != current_user.ut.uid) { 3105 errno = EPERM; 3106 return -1; 3107 } 3108 3100 3109 if (SMB_VFS_STAT(conn,fname,&st)) { 3101 3110 return -1; … … 3105 3114 return -1; 3106 3115 } 3107 3108 /* only allow chown to the current user. This is more secure,3109 and also copes with the case where the SID in a take ownership ACL is3110 a local SID on the users workstation3111 */3112 uid = current_user.ut.uid;3113 3116 3114 3117 become_root(); … … 3339 3342 BOOL acl_perms = False; 3340 3343 mode_t orig_mode = (mode_t)0; 3341 uid_t orig_uid;3342 gid_t orig_gid;3343 BOOL need_chown = False;3344 BOOL set_acl_as_root = false; 3345 BOOL acl_set_support = false; 3346 BOOL ret = false; 3344 3347 3345 3348 DEBUG(10,("set_nt_acl: called for file %s\n", fsp->fsp_name )); … … 3364 3367 /* Save the original elements we check against. */ 3365 3368 orig_mode = sbuf.st_mode; 3366 orig_uid = sbuf.st_uid;3367 orig_gid = sbuf.st_gid;3368 3369 3369 3370 /* … … 3379 3380 */ 3380 3381 3381 if (((user != (uid_t)-1) && (orig_uid != user)) || (( grp != (gid_t)-1) && (orig_gid != grp))) { 3382 need_chown = True; 3383 } 3384 3385 /* 3386 * Chown before setting ACL only if we don't change the user, or 3387 * if we change to the current user, but not if we want to give away 3388 * the file. 3389 */ 3390 3391 if (need_chown && (user == (uid_t)-1 || user == current_user.ut.uid)) { 3382 if (((user != (uid_t)-1) && (sbuf.st_uid != user)) || (( grp != (gid_t)-1) && (sbuf.st_gid != grp))) { 3392 3383 3393 3384 DEBUG(3,("set_nt_acl: chown %s. uid = %u, gid = %u.\n", … … 3411 3402 } else { 3412 3403 3413 int ret;3404 int sret; 3414 3405 3415 3406 if(fsp->fh->fd == -1) 3416 ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf);3407 sret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name, &sbuf); 3417 3408 else 3418 ret = SMB_VFS_FSTAT(fsp,fsp->fh->fd,&sbuf);3419 3420 if( ret != 0)3409 sret = SMB_VFS_FSTAT(fsp,fsp->fh->fd,&sbuf); 3410 3411 if(sret != 0) 3421 3412 return False; 3422 3413 } … … 3424 3415 /* Save the original elements we check against. */ 3425 3416 orig_mode = sbuf.st_mode; 3426 orig_uid = sbuf.st_uid; 3427 orig_gid = sbuf.st_gid;3428 3429 /* We did it, don't try again*/3430 need_chown = False;3417 3418 /* If we successfully chowned, we know we must 3419 * be able to set the acl, so do it as root. 3420 */ 3421 set_acl_as_root = true; 3431 3422 } 3432 3423 3433 3424 create_file_sids(&sbuf, &file_owner_sid, &file_grp_sid); 3434 3435 #if 03436 /* Disable this - prevents ACL inheritance from the ACL editor. JRA. */3437 3438 /* See here: http://www.codeproject.com/KB/winsdk/accessctrl2.aspx3439 * for details and also the log trace in bug #4308. JRA.3440 */3441 3442 if ((security_info_sent & DACL_SECURITY_INFORMATION) &&3443 psd->dacl != NULL &&3444 (psd->type & (SE_DESC_DACL_AUTO_INHERITED|3445 SE_DESC_DACL_AUTO_INHERIT_REQ))==3446 (SE_DESC_DACL_AUTO_INHERITED|3447 SE_DESC_DACL_AUTO_INHERIT_REQ) ) {3448 NTSTATUS status = append_parent_acl(fsp, &sbuf, psd, &psd);3449 if (!NT_STATUS_IS_OK(status)) {3450 return False;3451 }3452 }3453 #endif3454 3425 3455 3426 acl_perms = unpack_canon_ace( fsp, &sbuf, &file_owner_sid, &file_grp_sid, … … 3457 3428 3458 3429 /* Ignore W2K traverse DACL set. */ 3459 if (file_ace_list || dir_ace_list) { 3460 3461 if (!acl_perms) { 3462 DEBUG(3,("set_nt_acl: cannot set permissions\n")); 3430 if (!file_ace_list && !dir_ace_list) { 3431 return True; 3432 } 3433 3434 if (!acl_perms) { 3435 DEBUG(3,("set_nt_acl: cannot set permissions\n")); 3436 free_canon_ace_list(file_ace_list); 3437 free_canon_ace_list(dir_ace_list); 3438 return False; 3439 } 3440 3441 /* 3442 * Only change security if we got a DACL. 3443 */ 3444 3445 if(!(security_info_sent & DACL_SECURITY_INFORMATION) || (psd->dacl == NULL)) { 3446 free_canon_ace_list(file_ace_list); 3447 free_canon_ace_list(dir_ace_list); 3448 return True; 3449 } 3450 3451 /* 3452 * Try using the POSIX ACL set first. Fall back to chmod if 3453 * we have no ACL support on this filesystem. 3454 */ 3455 3456 if (acl_perms && file_ace_list) { 3457 if (set_acl_as_root) { 3458 become_root(); 3459 } 3460 ret = set_canon_ace_list(fsp, file_ace_list, False, sbuf.st_gid, &acl_set_support); 3461 if (set_acl_as_root) { 3462 unbecome_root(); 3463 } 3464 if (acl_set_support && ret == False) { 3465 DEBUG(3,("set_nt_acl: failed to set file acl on file %s (%s).\n", fsp->fsp_name, strerror(errno) )); 3463 3466 free_canon_ace_list(file_ace_list); 3464 free_canon_ace_list(dir_ace_list); 3467 free_canon_ace_list(dir_ace_list); 3465 3468 return False; 3466 3469 } 3467 3468 /* 3469 * Only change security if we got a DACL. 3470 */ 3471 3472 if((security_info_sent & DACL_SECURITY_INFORMATION) && (psd->dacl != NULL)) { 3473 3474 BOOL acl_set_support = False; 3475 BOOL ret = False; 3470 } 3471 3472 if (acl_perms && acl_set_support && fsp->is_directory) { 3473 if (dir_ace_list) { 3474 if (set_acl_as_root) { 3475 become_root(); 3476 } 3477 ret = set_canon_ace_list(fsp, dir_ace_list, True, sbuf.st_gid, &acl_set_support); 3478 if (set_acl_as_root) { 3479 unbecome_root(); 3480 } 3481 if (ret == False) { 3482 DEBUG(3,("set_nt_acl: failed to set default acl on directory %s (%s).\n", fsp->fsp_name, strerror(errno) )); 3483 free_canon_ace_list(file_ace_list); 3484 free_canon_ace_list(dir_ace_list); 3485 return False; 3486 } 3487 } else { 3488 3489 int sret = -1; 3476 3490 3477 3491 /* 3478 * Try using the POSIX ACL set first. Fall back to chmod if 3479 * we have no ACL support on this filesystem. 3492 * No default ACL - delete one if it exists. 3480 3493 */ 3481 3494 3482 if (acl_perms && file_ace_list) { 3483 ret = set_canon_ace_list(fsp, file_ace_list, False, sbuf.st_gid, &acl_set_support); 3484 if (acl_set_support && ret == False) { 3485 DEBUG(3,("set_nt_acl: failed to set file acl on file %s (%s).\n", fsp->fsp_name, strerror(errno) )); 3495 if (set_acl_as_root) { 3496 become_root(); 3497 } 3498 sret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, fsp->fsp_name); 3499 if (set_acl_as_root) { 3500 unbecome_root(); 3501 } 3502 3503 if (sret == -1) { 3504 if (acl_group_override(conn, sbuf.st_gid, fsp->fsp_name)) { 3505 DEBUG(5,("set_nt_acl: acl group control on and " 3506 "current user in file %s primary group. Override delete_def_acl\n", 3507 fsp->fsp_name )); 3508 3509 become_root(); 3510 sret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, fsp->fsp_name); 3511 unbecome_root(); 3512 } 3513 3514 if (sret == -1) { 3515 DEBUG(3,("set_nt_acl: sys_acl_delete_def_file failed (%s)\n", strerror(errno))); 3486 3516 free_canon_ace_list(file_ace_list); 3487 free_canon_ace_list(dir_ace_list); 3517 free_canon_ace_list(dir_ace_list); 3488 3518 return False; 3489 3519 } 3490 3520 } 3491 3492 if (acl_perms && acl_set_support && fsp->is_directory) { 3493 if (dir_ace_list) { 3494 if (!set_canon_ace_list(fsp, dir_ace_list, True, sbuf.st_gid, &acl_set_support)) { 3495 DEBUG(3,("set_nt_acl: failed to set default acl on directory %s (%s).\n", fsp->fsp_name, strerror(errno) )); 3496 free_canon_ace_list(file_ace_list); 3497 free_canon_ace_list(dir_ace_list); 3498 return False; 3499 } 3500 } else { 3501 3502 /* 3503 * No default ACL - delete one if it exists. 3504 */ 3505 3506 if (SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, fsp->fsp_name) == -1) { 3507 int sret = -1; 3508 3509 if (acl_group_override(conn, sbuf.st_gid, fsp->fsp_name)) { 3510 DEBUG(5,("set_nt_acl: acl group control on and " 3511 "current user in file %s primary group. Override delete_def_acl\n", 3512 fsp->fsp_name )); 3513 3514 become_root(); 3515 sret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, fsp->fsp_name); 3516 unbecome_root(); 3517 } 3518 3519 if (sret == -1) { 3520 DEBUG(3,("set_nt_acl: sys_acl_delete_def_file failed (%s)\n", strerror(errno))); 3521 free_canon_ace_list(file_ace_list); 3522 free_canon_ace_list(dir_ace_list); 3523 return False; 3524 } 3525 } 3521 } 3522 } 3523 3524 if (acl_set_support) { 3525 if (set_acl_as_root) { 3526 become_root(); 3527 } 3528 store_inheritance_attributes(fsp, file_ace_list, dir_ace_list, 3529 (psd->type & SE_DESC_DACL_PROTECTED) ? True : False); 3530 if (set_acl_as_root) { 3531 unbecome_root(); 3532 } 3533 } 3534 3535 /* 3536 * If we cannot set using POSIX ACLs we fall back to checking if we need to chmod. 3537 */ 3538 3539 if(!acl_set_support && acl_perms) { 3540 mode_t posix_perms; 3541 3542 if (!convert_canon_ace_to_posix_perms( fsp, file_ace_list, &posix_perms)) { 3543 free_canon_ace_list(file_ace_list); 3544 free_canon_ace_list(dir_ace_list); 3545 DEBUG(3,("set_nt_acl: failed to convert file acl to posix permissions for file %s.\n", 3546 fsp->fsp_name )); 3547 return False; 3548 } 3549 3550 if (orig_mode != posix_perms) { 3551 int sret = -1; 3552 3553 DEBUG(3,("set_nt_acl: chmod %s. perms = 0%o.\n", 3554 fsp->fsp_name, (unsigned int)posix_perms )); 3555 3556 if (set_acl_as_root) { 3557 become_root(); 3558 } 3559 sret = SMB_VFS_CHMOD(conn,fsp->fsp_name, posix_perms); 3560 if (set_acl_as_root) { 3561 unbecome_root(); 3562 } 3563 if(sret == -1) { 3564 if (acl_group_override(conn, sbuf.st_gid, fsp->fsp_name)) { 3565 DEBUG(5,("set_nt_acl: acl group control on and " 3566 "current user in file %s primary group. Override chmod\n", 3567 fsp->fsp_name )); 3568 3569 become_root(); 3570 sret = SMB_VFS_CHMOD(conn,fsp->fsp_name, posix_perms); 3571 unbecome_root(); 3526 3572 } 3527 } 3528 3529 if (acl_set_support) { 3530 store_inheritance_attributes(fsp, file_ace_list, dir_ace_list, 3531 (psd->type & SE_DESC_DACL_PROTECTED) ? True : False); 3532 } 3533 3534 /* 3535 * If we cannot set using POSIX ACLs we fall back to checking if we need to chmod. 3536 */ 3537 3538 if(!acl_set_support && acl_perms) { 3539 mode_t posix_perms; 3540 3541 if (!convert_canon_ace_to_posix_perms( fsp, file_ace_list, &posix_perms)) { 3573 3574 if (sret == -1) { 3575 DEBUG(3,("set_nt_acl: chmod %s, 0%o failed. Error = %s.\n", 3576 fsp->fsp_name, (unsigned int)posix_perms, strerror(errno) )); 3542 3577 free_canon_ace_list(file_ace_list); 3543 3578 free_canon_ace_list(dir_ace_list); 3544 DEBUG(3,("set_nt_acl: failed to convert file acl to posix permissions for file %s.\n",3545 fsp->fsp_name ));3546 3579 return False; 3547 3580 } 3548 3549 if (orig_mode != posix_perms) { 3550 3551 DEBUG(3,("set_nt_acl: chmod %s. perms = 0%o.\n", 3552 fsp->fsp_name, (unsigned int)posix_perms )); 3553 3554 if(SMB_VFS_CHMOD(conn,fsp->fsp_name, posix_perms) == -1) { 3555 int sret = -1; 3556 if (acl_group_override(conn, sbuf.st_gid, fsp->fsp_name)) { 3557 DEBUG(5,("set_nt_acl: acl group control on and " 3558 "current user in file %s primary group. Override chmod\n", 3559 fsp->fsp_name )); 3560 3561 become_root(); 3562 sret = SMB_VFS_CHMOD(conn,fsp->fsp_name, posix_perms); 3563 unbecome_root(); 3564 } 3565 3566 if (sret == -1) { 3567 DEBUG(3,("set_nt_acl: chmod %s, 0%o failed. Error = %s.\n", 3568 fsp->fsp_name, (unsigned int)posix_perms, strerror(errno) )); 3569 free_canon_ace_list(file_ace_list); 3570 free_canon_ace_list(dir_ace_list); 3571 return False; 3572 } 3573 } 3574 } 3575 } 3576 } 3577 3578 free_canon_ace_list(file_ace_list); 3579 free_canon_ace_list(dir_ace_list); 3580 } 3581 3582 /* Any chown pending? */ 3583 if (need_chown) { 3584 3585 DEBUG(3,("set_nt_acl: chown %s. uid = %u, gid = %u.\n", 3586 fsp->fsp_name, (unsigned int)user, (unsigned int)grp )); 3587 3588 if(try_chown( fsp->conn, fsp->fsp_name, user, grp) == -1) { 3589 DEBUG(3,("set_nt_acl: chown %s, %u, %u failed. Error = %s.\n", 3590 fsp->fsp_name, (unsigned int)user, (unsigned int)grp, strerror(errno) )); 3591 return False; 3592 } 3593 } 3594 3581 } 3582 } 3583 } 3584 3585 free_canon_ace_list(file_ace_list); 3586 free_canon_ace_list(dir_ace_list); 3595 3587 return True; 3596 3588 } … … 3969 3961 SMB_ACL_T def_acl = NULL; 3970 3962 3971 if (num_def_acls && !S_ISDIR(psbuf->st_mode)) { 3972 DEBUG(5,("set_unix_posix_default_acl: Can't set default ACL on non-directory file %s\n", fname )); 3973 errno = EISDIR; 3974 return False; 3963 if (!S_ISDIR(psbuf->st_mode)) { 3964 if (num_def_acls) { 3965 DEBUG(5,("set_unix_posix_default_acl: Can't set default ACL on non-directory file %s\n", fname )); 3966 errno = EISDIR; 3967 return false; 3968 } else { 3969 return true; 3970 } 3975 3971 } 3976 3972 -
branches/samba-3.0/source/smbd/server.c
r165 r312 1120 1120 1121 1121 if (*lp_rootdir()) { 1122 if (sys_chroot(lp_rootdir()) == 0) 1123 DEBUG(2,("Changed root to %s\n", lp_rootdir())); 1122 if (sys_chroot(lp_rootdir()) != 0) { 1123 DEBUG(0,("Failed to change root to %s\n", lp_rootdir())); 1124 exit(1); 1125 } 1126 if (chdir("/") == -1) { 1127 DEBUG(0,("Failed to chdir to / on chroot to %s\n", lp_rootdir())); 1128 exit(1); 1129 } 1130 DEBUG(0,("Changed root to %s\n", lp_rootdir())); 1124 1131 } 1125 1132 -
branches/samba-3.0/source/smbd/trans2.c
r165 r312 5482 5482 } else if((wire_open_mode & SMB_O_CREAT) == SMB_O_CREAT) { 5483 5483 create_disp = FILE_OPEN_IF; 5484 } else if ((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL | SMB_O_TRUNC)) == 0) { 5485 create_disp = FILE_OPEN; 5484 5486 } else { 5485 5487 DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n",
Note:
See TracChangeset
for help on using the changeset viewer.