Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/web/cgi.c

    r617 r745  
    22   some simple CGI helper routines
    33   Copyright (C) Andrew Tridgell 1997-1998
    4    
     4
    55   This program is free software; you can redistribute it and/or modify
    66   it under the terms of the GNU General Public License as published by
    77   the Free Software Foundation; either version 3 of the License, or
    88   (at your option) any later version.
    9    
     9
    1010   This program is distributed in the hope that it will be useful,
    1111   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1212   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1313   GNU General Public License for more details.
    14    
     14
    1515   You should have received a copy of the GNU General Public License
    1616   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    1919
    2020#include "includes.h"
     21
     22
    2123#include "web/swat_proto.h"
     24
     25
    2226#include "secrets.h"
    23 #include "../lib/util/util.h"
    2427
    2528#define MAX_VARIABLES 10000
     
    5760        while ((*cl)) {
    5861                int c;
    59        
     62
    6063                if (i == len) {
    6164                        char *ret2;
     
    6669                        ret = ret2;
    6770                }
    68        
     71
    6972                c = fgetc(f);
    7073                (*cl)--;
     
    7477                        break;
    7578                }
    76                
     79
    7780                if (c == '\r') continue;
    7881
     
    8285
    8386        }
    84        
     87
    8588        if (ret) {
    8689                ret[i] = 0;
     
    136139                        p = strchr_m(line,'=');
    137140                        if (!p) continue;
    138                        
     141
    139142                        *p = 0;
    140                        
     143
    141144                        variables[num_variables].name = SMB_STRDUP(line);
    142145                        variables[num_variables].value = SMB_STRDUP(p+1);
    143146
    144147                        SAFE_FREE(line);
    145                        
     148
    146149                        if (!variables[num_variables].name ||
    147150                            !variables[num_variables].value)
     
    158161                               variables[num_variables].value);
    159162#endif
    160                        
     163
    161164                        num_variables++;
    162165                        if (num_variables == MAX_VARIABLES) break;
     
    173176                        p = strchr_m(tok,'=');
    174177                        if (!p) continue;
    175                        
     178
    176179                        *p = 0;
    177                        
     180
    178181                        variables[num_variables].name = SMB_STRDUP(tok);
    179182                        variables[num_variables].value = SMB_STRDUP(p+1);
     
    319322
    320323#ifndef __OS2__
    321         pwd = Get_Pwnam_alloc(talloc_autofree_context(), user);
    322        
     324        pwd = Get_Pwnam_alloc(talloc_tos(), user);
    323325        if (!pwd) {
    324326                printf("%sCannot find user %s<br>%s\n", head, user, tail);
     
    332334                if (C_pass == NULL) {
    333335                        char *tmp_pass = NULL;
    334                         tmp_pass = generate_random_str(talloc_tos(), 16);
     336                        tmp_pass = generate_random_password(talloc_tos(),
     337                                                            16, 16);
    335338                        if (tmp_pass == NULL) {
    336339                                printf("%sFailed to create random nonce for "
     
    362365        fstring user, user_pass;
    363366        struct passwd *pass = NULL;
     367
     368
    364369
    365370        if (!strnequal(line,"Basic ", 6)) {
     
    389394         * Try and get the user from the UNIX password file.
    390395         */
    391        
    392         pass = Get_Pwnam_alloc(talloc_autofree_context(), user);
    393        
     396
     397        pass = Get_Pwnam_alloc(talloc_tos(), user);
     398
     399        rhost = client_name(1);
     400        if (strequal(rhost,"UNKNOWN"))
     401                rhost = client_addr(1, addr, sizeof(addr));
     402
    394403        /*
    395404         * Validate the password they have given.
    396405         */
    397        
    398         if NT_STATUS_IS_OK(pass_check(pass, user, user_pass,
    399                       strlen(user_pass), NULL, False)) {
    400                
     406
     407        if NT_STATUS_IS_OK(pass_check(pass, user, rhost, user_pass, false)) {
    401408                if (pass) {
    402409                        /*
    403410                         * Password was ok.
    404411                         */
    405                        
     412
    406413                        if ( initgroups(pass->pw_name, pass->pw_gid) != 0 )
    407414                                goto err;
    408415
    409416                        become_user_permanently(pass->pw_uid, pass->pw_gid);
    410                        
     417
    411418                        /* Save the users name */
    412419                        C_user = SMB_STRDUP(user);
     
    416423                }
    417424        }
    418        
     425
    419426err:
    420427        cgi_setup_error("401 Bad Authorization",
     
    539546
    540547
     548
     549
     550
     551
     552
     553
     554
     555
     556
     557
     558
     559
     560
     561
     562
     563
     564
     565
     566
     567
     568
     569
     570
     571
     572
     573
     574
     575
     576
     577
     578
     579
     580
     581
     582
     583
     584
     585
     586
     587
     588
     589
     590
     591
     592
     593
     594
     595
     596
     597
     598
     599
     600
     601
     602
     603
     604
     605
     606
     607
     608
     609
     610
     611
     612
     613
     614
     615
     616
     617
     618
     619
     620
     621
     622
     623
     624
     625
     626
     627
     628
    541629
    542630/**
Note: See TracChangeset for help on using the changeset viewer.