~ubuntu-branches/ubuntu/gutsy/samba/gutsy-updates

« back to all changes in this revision

Viewing changes to source/nsswitch/winbindd.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2006-11-28 20:14:37 UTC
  • mfrom: (0.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061128201437-a6x4lzlhempazocp
Tags: 3.0.23d-1ubuntu1
* Merge from debian unstable.
* Drop python2.4-samba, replace with python-samba. Added Conflicts/Replaces
  on python2.4-samba
* Drop track-connection-dos.patch, ubuntu-winbind-panic.patch, 
  ubuntu-fix-ldap.patch, ubuntu-setlocale.patch, ubuntu-setlocale-fixes.patch
* Remaining Ubuntu changes:
  - Revert Debian's installation of mount.cifs and umount.cifs as suid
  - Comment out the default [homes] shares and add more verbose comments to
    explain what they do and how they work (closes: launchpad.net/27608)
  - Add a "valid users = %S" stanza to the commented-out [homes] section, to
    show users how to restrict access to \\server\username to only username.
  - Change the (commented-out) "printer admin" example to use "@lpadmin"
    instead of "@ntadmin", since the lpadmin group is used for spool admin.
  - Alter the panic-action script to encourage users to report their
    bugs in Ubuntu packages to Ubuntu, rather than reporting to Debian.
    Modify text to more closely match the Debian script
  - Munge our init script to deal with the fact that our implementation
    (or lack thereof) of log_daemon_msg and log_progress_msg differs
    from Debian's implementation of the same (Ubuntu #19691)
  - Kept ubuntu-auxsrc.patch: some auxilliary sources (undocumented in 
    previous changelogs)
  - Set default workgroup to MSHOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "includes.h"
27
27
#include "winbindd.h"
28
28
 
 
29
#undef DBGC_CLASS
 
30
#define DBGC_CLASS DBGC_WINBIND
 
31
 
29
32
BOOL opt_nocache = False;
30
33
static BOOL interactive = False;
31
34
 
47
50
        }
48
51
 
49
52
        reopen_logs();
50
 
        ret = lp_load(dyn_CONFIGFILE,False,False,True);
 
53
        ret = lp_load(dyn_CONFIGFILE,False,False,True,True);
51
54
 
52
55
        reopen_logs();
53
56
        load_interfaces();
56
59
}
57
60
 
58
61
 
59
 
#if DUMP_CORE
60
 
 
61
 
/**************************************************************************** **
62
 
 Prepare to dump a core file - carefully!
63
 
 **************************************************************************** */
64
 
 
65
 
static BOOL dump_core(void)
66
 
{
67
 
        char *p;
68
 
        pstring dname;
69
 
        pstrcpy( dname, lp_logfile() );
70
 
        if ((p=strrchr(dname,'/')))
71
 
                *p=0;
72
 
        pstrcat( dname, "/corefiles" );
73
 
        mkdir( dname, 0700 );
74
 
        sys_chown( dname, getuid(), getgid() );
75
 
        chmod( dname, 0700 );
76
 
        if ( chdir(dname) )
77
 
                return( False );
78
 
        umask( ~(0700) );
79
 
 
80
 
#ifdef HAVE_GETRLIMIT
81
 
#ifdef RLIMIT_CORE
82
 
        {
83
 
                struct rlimit rlp;
84
 
                getrlimit( RLIMIT_CORE, &rlp );
85
 
                rlp.rlim_cur = MAX( 4*1024*1024, rlp.rlim_cur );
86
 
                setrlimit( RLIMIT_CORE, &rlp );
87
 
                getrlimit( RLIMIT_CORE, &rlp );
88
 
                DEBUG( 3, ( "Core limits now %d %d\n", (int)rlp.rlim_cur, (int)rlp.rlim_max ) );
89
 
        }
90
 
#endif
91
 
#endif
92
 
 
93
 
        DEBUG(0,("Dumping core in %s\n",dname));
94
 
        abort();
95
 
        return( True );
96
 
} /* dump_core */
97
 
#endif
98
 
 
99
62
/**************************************************************************** **
100
63
 Handle a fault..
101
64
 **************************************************************************** */
120
83
        if (DEBUGLEVEL >= 2 && winbindd_num_clients()) {
121
84
                DEBUG(2, ("\tclient list:\n"));
122
85
                for(tmp = winbindd_client_list(); tmp; tmp = tmp->next) {
123
 
                        DEBUG(2, ("\t\tpid %lu, sock %d\n",
 
86
                        DEBUGADD(2, ("\t\tpid %lu, sock %d\n",
124
87
                                  (unsigned long)tmp->pid, tmp->sock));
125
88
                }
126
89
        }
250
213
        { WINBINDD_PAM_AUTH, winbindd_pam_auth, "PAM_AUTH" },
251
214
        { WINBINDD_PAM_AUTH_CRAP, winbindd_pam_auth_crap, "AUTH_CRAP" },
252
215
        { WINBINDD_PAM_CHAUTHTOK, winbindd_pam_chauthtok, "CHAUTHTOK" },
 
216
        { WINBINDD_PAM_LOGOFF, winbindd_pam_logoff, "PAM_LOGOFF" },
253
217
 
254
218
        /* Enumeration functions */
255
219
 
270
234
        { WINBINDD_SID_TO_GID, winbindd_sid_to_gid, "SID_TO_GID" },
271
235
        { WINBINDD_UID_TO_SID, winbindd_uid_to_sid, "UID_TO_SID" },
272
236
        { WINBINDD_GID_TO_SID, winbindd_gid_to_sid, "GID_TO_SID" },
273
 
        { WINBINDD_ALLOCATE_RID, winbindd_allocate_rid, "ALLOCATE_RID" },
274
 
        { WINBINDD_ALLOCATE_RID_AND_GID, winbindd_allocate_rid_and_gid,
275
 
          "ALLOCATE_RID_AND_GID" },
 
237
        { WINBINDD_ALLOCATE_UID, winbindd_allocate_uid, "ALLOCATE_UID" },
 
238
        { WINBINDD_ALLOCATE_GID, winbindd_allocate_gid, "ALLOCATE_GID" },
276
239
 
277
240
        /* Miscellaneous */
278
241
 
305
268
        /* Free response data - we may be interrupted and receive another
306
269
           command before being able to send this data off. */
307
270
 
308
 
        SAFE_FREE(state->response.extra_data);  
 
271
        SAFE_FREE(state->response.extra_data.data);  
309
272
 
310
273
        ZERO_STRUCT(state->response);
311
274
 
475
438
                return;
476
439
        }
477
440
 
478
 
        SAFE_FREE(state->request.extra_data);
479
 
        SAFE_FREE(state->response.extra_data);
 
441
        SAFE_FREE(state->request.extra_data.data);
 
442
        SAFE_FREE(state->response.extra_data.data);
480
443
 
481
444
        setup_async_read(&state->fd_event, &state->request, sizeof(uint32),
482
445
                         request_len_recv, state);
503
466
                return;
504
467
        }
505
468
 
506
 
        setup_async_write(&state->fd_event, state->response.extra_data,
 
469
        setup_async_write(&state->fd_event, state->response.extra_data.data,
507
470
                          state->response.length - sizeof(state->response),
508
471
                          response_extra_sent, state);
509
472
}
572
535
        }
573
536
 
574
537
        if (state->request.extra_len == 0) {
575
 
                state->request.extra_data = NULL;
 
538
                state->request.extra_data.data = NULL;
576
539
                request_recv(state, True);
577
540
                return;
578
541
        }
581
544
            (state->request.extra_len > WINBINDD_MAX_EXTRA_DATA)) {
582
545
                DEBUG(3, ("Got request with %d bytes extra data on "
583
546
                          "unprivileged socket\n", (int)state->request.extra_len));
584
 
                state->request.extra_data = NULL;
 
547
                state->request.extra_data.data = NULL;
585
548
                state->finished = True;
586
549
                return;
587
550
        }
588
551
 
589
 
        state->request.extra_data =
 
552
        state->request.extra_data.data =
590
553
                SMB_MALLOC_ARRAY(char, state->request.extra_len + 1);
591
554
 
592
 
        if (state->request.extra_data == NULL) {
 
555
        if (state->request.extra_data.data == NULL) {
593
556
                DEBUG(0, ("malloc failed\n"));
594
557
                state->finished = True;
595
558
                return;
596
559
        }
597
560
 
598
561
        /* Ensure null termination */
599
 
        state->request.extra_data[state->request.extra_len] = '\0';
 
562
        state->request.extra_data.data[state->request.extra_len] = '\0';
600
563
 
601
 
        setup_async_read(&state->fd_event, state->request.extra_data,
 
564
        setup_async_read(&state->fd_event, state->request.extra_data.data,
602
565
                         state->request.extra_len, request_recv, state);
603
566
}
604
567
 
680
643
                /* We may have some extra data that was not freed if the
681
644
                   client was killed unexpectedly */
682
645
 
683
 
                SAFE_FREE(state->response.extra_data);
 
646
                SAFE_FREE(state->response.extra_data.data);
684
647
 
685
648
                if (state->mem_ctx != NULL) {
686
649
                        talloc_destroy(state->mem_ctx);
692
655
                /* Remove from list and free */
693
656
                
694
657
                winbindd_remove_client(state);
695
 
                talloc_free(state);
 
658
                TALLOC_FREE(state);
696
659
        }
697
660
}
698
661
 
751
714
 
752
715
        /* Free up temporary memory */
753
716
 
754
 
        lp_talloc_free();
755
 
        main_loop_talloc_free();
 
717
        lp_TALLOC_FREE();
 
718
        main_loop_TALLOC_FREE();
756
719
 
757
720
        /* Initialise fd lists for select() */
758
721
 
806
769
        
807
770
        selret = sys_select(maxfd + 1, &r_fds, &w_fds, NULL, &timeout);
808
771
 
809
 
        if (selret == 0)
 
772
        if (selret == 0) {
810
773
                goto no_fds_ready;
 
774
        }
811
775
 
812
 
        if ((selret == -1 && errno != EINTR) || selret == 0) {
 
776
        if (selret == -1) {
 
777
                if (errno == EINTR) {
 
778
                        goto no_fds_ready;
 
779
                }
813
780
 
814
781
                /* Select error, something is badly wrong */
815
782
 
817
784
                exit(1);
818
785
        }
819
786
 
 
787
        /* selret > 0 */
 
788
 
820
789
        ev = fd_events;
821
790
        while (ev != NULL) {
822
791
                struct fd_event *next = ev->next;
912
881
        pstring logfile;
913
882
        static BOOL Fork = True;
914
883
        static BOOL log_stdout = False;
 
884
        static BOOL no_process_group = False;
915
885
        struct poptOption long_options[] = {
916
886
                POPT_AUTOHELP
917
887
                { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
918
888
                { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" },
 
889
                { "no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" },
919
890
                { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
920
891
                { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, True, "Disable caching" },
921
892
                POPT_COMMON_SAMBA
931
902
        CatchSignal(SIGUSR2, SIG_IGN);
932
903
 
933
904
        fault_setup((void (*)(void *))fault_quit );
 
905
        dump_core_setup("winbindd");
934
906
 
935
907
        load_case_tables();
936
908
 
943
915
        /* Set environment variable so we don't recursively call ourselves.
944
916
           This may also be useful interactively. */
945
917
 
946
 
        setenv(WINBINDD_DONT_ENV, "1", 1);
 
918
        if ( !winbind_off() ) {
 
919
                DEBUG(0,("Failed to disable recusive winbindd calls.  Exiting.\n"));
 
920
                exit(1);
 
921
        }
947
922
 
948
923
        /* Initialise samba/rpc client stuff */
949
924
 
1036
1011
        CatchSignal(SIGHUP, sighup_handler);
1037
1012
 
1038
1013
        if (!interactive)
1039
 
                become_daemon(Fork);
 
1014
                become_daemon(Fork, no_process_group);
1040
1015
 
1041
1016
        pidfile_create("winbindd");
1042
1017
 
1045
1020
         * If we're interactive we want to set our own process group for
1046
1021
         * signal management.
1047
1022
         */
1048
 
        if (interactive)
 
1023
        if (interactive && !no_process_group)
1049
1024
                setpgid( (pid_t)0, (pid_t)0);
1050
1025
#endif
1051
1026
 
1054
1029
        /* Initialise messaging system */
1055
1030
 
1056
1031
        if (!message_init()) {
1057
 
                DEBUG(0, ("unable to initialise messaging system\n"));
 
1032
                DEBUG(0, ("unable to initialize messaging system\n"));
1058
1033
                exit(1);
1059
1034
        }
1060
1035
        
1062
1037
           as to SIGHUP signal */
1063
1038
        message_register(MSG_SMB_CONF_UPDATED, msg_reload_services);
1064
1039
        message_register(MSG_SHUTDOWN, msg_shutdown);
1065
 
        
 
1040
 
 
1041
        /* Handle online/offline messages. */
 
1042
        message_register(MSG_WINBIND_OFFLINE,winbind_msg_offline);
 
1043
        message_register(MSG_WINBIND_ONLINE,winbind_msg_online);
 
1044
        message_register(MSG_WINBIND_ONLINESTATUS,winbind_msg_onlinestatus);
 
1045
 
1066
1046
        poptFreeContext(pc);
1067
1047
 
1068
1048
        netsamlogon_cache_init(); /* Non-critical */
1069
1049
        
1070
 
        init_domain_list();
 
1050
        if (!init_domain_list()) {
 
1051
                DEBUG(0,("unable to initalize domain list\n"));
 
1052
                exit(1);
 
1053
        }
1071
1054
 
1072
1055
        init_idmap_child();
1073
1056
 
 
1057
        smb_nscd_flush_user_cache();
 
1058
        smb_nscd_flush_group_cache();
 
1059
 
1074
1060
        /* Loop waiting for requests */
1075
1061
 
1076
1062
        while (1)