Ignore:
Timestamp:
Jul 11, 2008, 1:13:42 AM (17 years ago)
Author:
Paul Smedley
Message:

Update branch to 3.0.31 release

Location:
branches/samba-3.0/source/nsswitch
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/nsswitch/idmap_util.c

    r30 r140  
    159159
    160160        if ((map.status != ID_MAPPED) || (map.xid.type != ID_TYPE_GID)) {
    161                 DEBUG(10, ("sid [%s] not mapped to an gid [%u,%u,%u]\n",
     161                DEBUG(10, ("sid [%s] not mapped to an gid [%u,%u]\n",
    162162                           sid_string_static(sid),
    163163                           map.status,
    164                            map.xid.type,
    165                            map.xid.id));
     164                           map.xid.type));
    166165                return NT_STATUS_NONE_MAPPED;
    167166        }
  • branches/samba-3.0/source/nsswitch/pam_winbind.c

    r124 r140  
    11821182        }
    11831183
     1184        if (ctrl & WINBIND_CACHED_LOGIN) {
     1185                request.flags |= WBFLAG_PAM_CACHED_LOGIN;
     1186        }
     1187
    11841188        ret = pam_winbind_request_log(pamh, ctrl, WINBINDD_PAM_CHAUTHTOK, &request, &response, user);
    11851189
     
    19081912{
    19091913
    1910         /* Make sure that we only do this if 
     1914        /* Make sure that we only do this if
    19111915         * a) the chauthtok got initiated during a logon attempt (authenticate->acct_mgmt->chauthtok)
    19121916         * b) any later password change via the "passwd" command if done by the user itself
    1913          */
    1914                
     1917         *
     1918         * NB. If we login from gdm or xdm and the password expires,
     1919         * we change the password, but there is no memory cache.
     1920         * Thus, even for passthrough login, we should do the
     1921         * authentication again to update memory cache.
     1922         * --- BoYang
     1923         * */
     1924
    19151925        char *new_authtok_reqd_during_auth = NULL;
    19161926        struct passwd *pwd = NULL;
    1917 
    1918         if (!(ctrl & WINBIND_KRB5_AUTH)) {
    1919                 return False;
    1920         }
    19211927
    19221928        _pam_get_data(pamh, PAM_WINBIND_NEW_AUTHTOK_REQD_DURING_AUTH, &new_authtok_reqd_during_auth);
     
    19471953        int ret;
    19481954        unsigned int ctrl;
     1955        bool cached_login = False;
    19491956
    19501957        /* <DO NOT free() THESE> */
     
    19701977        _PAM_LOG_FUNCTION_ENTER("pam_sm_chauthtok", pamh, ctrl, flags);
    19711978
    1972         /* clearing offline bit for the auth in the password change */
     1979        cached_login = (ctrl & WINBIND_CACHED_LOGIN);
     1980
     1981        /* clearing offline bit for auth */
    19731982        ctrl &= ~WINBIND_CACHED_LOGIN;
    19741983
     
    21182127                               &pwdlastset_update);
    21192128
     2129                /*
     2130                 * if cached creds were enabled, make sure to set the
     2131                 * WINBIND_CACHED_LOGIN bit here in order to have winbindd
     2132                 * update the cached creds storage - gd
     2133                 */
     2134                if (cached_login) {
     2135                        ctrl |= WINBIND_CACHED_LOGIN;
     2136                }
     2137
    21202138                ret = winbind_chauthtok_request(pamh, ctrl, user, pass_old, pass_new, pwdlastset_update);
    21212139                if (ret) {
     
    21302148                        const char *member = get_member_from_config(pamh, argc, argv, ctrl, d);
    21312149                        const char *cctype = get_krb5_cc_type_from_config(pamh, argc, argv, ctrl, d);
     2150
     2151                        /* Keep the WINBIND_CACHED_LOGIN bit for
     2152                         * authentication after changing the password.
     2153                         * This will update the cached credentials in case
     2154                         * that winbindd_dual_pam_chauthtok() fails
     2155                         * to update them.
     2156                         * --- BoYang
     2157                         * */
    21322158
    21332159                        ret = winbind_auth_request(pamh, ctrl, user, pass_new,
  • branches/samba-3.0/source/nsswitch/winbindd.c

    r134 r140  
    118118/* Handle the signal by unlinking socket and exiting */
    119119
    120 static void terminate(void)
    121 {
    122         pstring path;
    123 
    124         /* Remove socket file */
    125         pstr_sprintf(path, "%s/%s",
    126                  WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME);
    127         unlink(path);
     120static void terminate(bool in_parent)
     121{
     122        if (in_parent) {
     123                /* When parent goes away we should
     124                 * remove the socket file. Not so
     125                 * when children terminate.
     126                 */
     127
     128                pstring path;
     129
     130                /* Remove socket file */
     131                pstr_sprintf(path, "%s/%s",
     132                        WINBINDD_SOCKET_DIR, WINBINDD_SOCKET_NAME);
     133                unlink(path);
     134        }
    128135
    129136        idmap_close();
     
    732739
    733740/* check if TERM has been received */
    734 void winbind_check_sigterm(void)
     741void winbind_check_sigterm(bool in_parent)
    735742{
    736743        if (do_sigterm)
    737                 terminate();
     744                terminate(in_parent);
    738745}
    739746
     
    902909        /* Check signal handling things */
    903910
    904         winbind_check_sigterm();
     911        winbind_check_sigterm(true);
    905912        winbind_check_sighup();
    906913
  • branches/samba-3.0/source/nsswitch/winbindd_cache.c

    r134 r140  
    3838extern struct winbindd_methods ads_methods;
    3939#endif
    40 extern struct winbindd_methods passdb_methods;
     40extern struct winbindd_methods builtin_passdb_methods;
    4141
    4242/*
     
    139139
    140140        if (domain->internal) {
    141                 domain->backend = &passdb_methods;
     141                domain->backend = &builtin_passdb_methods;
    142142                domain->initialized = True;
    143143        }
  • branches/samba-3.0/source/nsswitch/winbindd_cm.c

    r134 r140  
    608608        }
    609609
    610         /* this is at least correct when domain is our domain,
    611          * which is the only case, when this is currently used: */
     610        /* For now assume our machine account only exists in our domain */
     611
    612612        if (machine_krb5_principal != NULL)
    613613        {
    614614                if (asprintf(machine_krb5_principal, "%s$@%s",
    615                              account_name, domain->alt_name) == -1)
     615                             account_name, lp_realm()) == -1)
    616616                {
    617617                        return NT_STATUS_NO_MEMORY;
     
    730730                        (*cli)->use_kerberos = True;
    731731                        DEBUG(5, ("connecting to %s from %s with kerberos principal "
    732                                   "[%s]\n", controller, global_myname(),
    733                                   machine_krb5_principal));
     732                                  "[%s] and realm [%s]\n", controller, global_myname(),
     733                                  machine_krb5_principal, domain->alt_name));
    734734
    735735                        ads_status = cli_session_setup_spnego(*cli,
    736736                                                              machine_krb5_principal,
    737737                                                              machine_password,
    738                                                               domain->name);
     738                                                              lp_workgroup(),
     739                                                              domain->alt_name);
    739740
    740741                        if (!ADS_ERR_OK(ads_status)) {
     
    756757                DEBUG(5, ("connecting to %s from %s with username "
    757758                          "[%s]\\[%s]\n",  controller, global_myname(),
    758                           domain->name, machine_account));
     759                          lp_workgroup(), machine_account));
    759760
    760761                ads_status = cli_session_setup_spnego(*cli,
    761762                                                      machine_account,
    762763                                                      machine_password,
    763                                                       domain->name);
     764                                                      lp_workgroup(),
     765                                                      NULL);
    764766                if (!ADS_ERR_OK(ads_status)) {
    765767                        DEBUG(4, ("authenticated session setup failed with %s\n",
     
    12491251        int i, fd_index;
    12501252
     1253        *fd = -1;
     1254
    12511255 again:
    12521256        if (!get_dcs(mem_ctx, domain, &dcs, &num_dcs) || (num_dcs == 0))
     
    13091313        winbind_add_failed_connection_entry(domain, dcs[fd_index].name,
    13101314                                    NT_STATUS_UNSUCCESSFUL);
     1315
     1316        /* Throw away all arrays as we're doing this again. */
     1317        TALLOC_FREE(dcs);
     1318        num_dcs = 0;
     1319
     1320        TALLOC_FREE(dcnames);
     1321        num_dcnames = 0;
     1322
     1323        TALLOC_FREE(addrs);
     1324        num_addrs = 0;
     1325
     1326        *fd = -1;
     1327
    13111328        goto again;
    13121329}
  • branches/samba-3.0/source/nsswitch/winbindd_dual.c

    r134 r140  
    3636
    3737extern BOOL override_logfile;
    38 extern struct winbindd_methods cache_methods;
    3938
    4039/* Read some data from a client connection */
     
    888887        struct winbindd_cli_state state;
    889888        struct winbindd_domain *domain;
     889        struct winbindd_domain *primary_domain = NULL;
    890890
    891891        if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair) != 0) {
     
    967967
    968968        /* Ensure we have no pending check_online events other
    969            than one for this domain. */
     969           than one for this domain or the primary domain. */
    970970
    971971        for (domain = domain_list(); domain; domain = domain->next) {
    972                 if (domain != child->domain) {
     972                if (domain->primary) {
     973                        primary_domain = domain;
     974                }
     975                if ((domain != child->domain) && !domain->primary) {
    973976                        TALLOC_FREE(domain->check_online_event);
    974977                }
     
    986989
    987990                set_domain_online_request(child->domain);
     991
     992                if (primary_domain != child->domain) {
     993                        /* We need to talk to the primary
     994                         * domain as well as the trusted
     995                         * domain inside a trusted domain
     996                         * child.
     997                         * See the code in :
     998                         * winbindd_dual_pam_auth_samlogon()
     999                         * especially the calling of
     1000                         * contact_domain = find_our_domain()
     1001                         * in the non-DC case for details.
     1002                         */
     1003                        set_domain_online_request(primary_domain);
     1004                }
    9881005
    9891006                child->lockout_policy_event = event_add_timed(
     
    9941011        }
    9951012
    996         /* Special case for Winbindd on a Samba DC,
    997          * We want to make sure the child can connect to smbd
    998          * but not the main daemon */
    999 
    1000         if (child->domain && child->domain->internal && IS_DC) {
    1001                 child->domain->methods = &cache_methods;
    1002                 child->domain->online = False;
    1003         }
    1004 
    10051013        while (1) {
    10061014
     
    10161024
    10171025                /* check for signals */
    1018                 winbind_check_sigterm();
     1026                winbind_check_sigterm(false);
    10191027                winbind_check_sighup();
    10201028
  • branches/samba-3.0/source/nsswitch/winbindd_group.c

    r39 r140  
    13991399        s->state->response.data.num_entries = s->num_token_gids;
    14001400        /* s->token_gids are talloced */
    1401         s->state->response.extra_data.data = smb_xmemdup(s->token_gids, s->num_token_gids * sizeof(gid_t));
    1402         s->state->response.length += s->num_token_gids * sizeof(gid_t);
     1401        if (s->num_token_gids != 0) {
     1402                s->state->response.extra_data.data = smb_xmemdup(
     1403                        s->token_gids, s->num_token_gids * sizeof(gid_t));
     1404                s->state->response.length += s->num_token_gids * sizeof(gid_t);
     1405        }
    14031406        request_ok(s->state);
    14041407}
  • branches/samba-3.0/source/nsswitch/winbindd_pam.c

    r124 r140  
    13801380                    NT_STATUS_EQUAL(result, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
    13811381                        DEBUG(10,("winbindd_dual_pam_auth_kerberos setting domain to offline\n"));
    1382                         domain->online = False;
     1382                        /* Use set_domain_offline() instead of
     1383                         * just set status offline, otherwise,
     1384                         * domain will never goes online again
     1385                         * --- BoYang */
     1386                        set_domain_offline(domain);
    13831387                }
    13841388
     
    20452049
    20462050        if (NT_STATUS_IS_OK(result) && (state->request.flags & WBFLAG_PAM_CACHED_LOGIN)) {
    2047                
     2051
    20482052                /* Update the single sign-on memory creds. */
    20492053                result = winbindd_replace_memory_creds(state->request.data.chauthtok.user,
    20502054                                                        newpass);
     2055
     2056                /* When we login from gdm or xdm and password expires,
     2057                 * we change the password, but there are no memory crendentials.
     2058                 * So, winbindd_replace_memory_creds() returns
     2059                 * NT_STATUS_OBJECT_NAME_NOT_FOUND. This is not a failure.
     2060                 * --- BoYang
     2061                 * */
     2062                if (NT_STATUS_EQUAL(result, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
     2063                        result = NT_STATUS_OK;
     2064                }
    20512065
    20522066                if (!NT_STATUS_IS_OK(result)) {
     
    20592073                                                         state->mem_ctx, user,
    20602074                                                         newpass);
     2075                        /* Again, this happens when we login from gdm or xdm
     2076                         * and the password expires, *BUT* cached crendentials
     2077                         * don't exist. winbindd_update_creds_by_name()
     2078                         * returns NT_STATUS_NO_SUCH_USER.
     2079                         * This is not a failure.
     2080                         * --- BoYang
     2081                         * */
     2082                        if (NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_USER)) {
     2083                                result = NT_STATUS_OK;
     2084                        }
    20612085                        if (!NT_STATUS_IS_OK(result)) {
    20622086                                DEBUG(10,("Failed to store creds: %s\n", nt_errstr(result)));
     
    20642088                        }
    20652089                }
    2066         }               
     2090        }
    20672091
    20682092        if (!NT_STATUS_IS_OK(result) && !got_info && contact_domain) {
  • branches/samba-3.0/source/nsswitch/winbindd_passdb.c

    r39 r140  
    77   Copyright (C) Simo Sorce 2003
    88   Copyright (C) Volker Lendecke 2004
     9   Copyright (C) Jeremy Allison 2008
    910   
    1011   This program is free software; you can redistribute it and/or modify
     
    2930#define DBGC_CLASS DBGC_WINBIND
    3031
    31 /* Query display info for a domain.  This returns enough information plus a
    32    bit extra to give an overview of domain users for the User Manager
    33    application. */
    34 static NTSTATUS query_user_list(struct winbindd_domain *domain,
    35                                TALLOC_CTX *mem_ctx,
    36                                uint32 *num_entries,
    37                                WINBIND_USERINFO **info)
    38 {
    39         /* We don't have users */
    40         *num_entries = 0;
    41         *info = NULL;
    42         return NT_STATUS_OK;
    43 }
    44 
    45 /* list all domain groups */
    46 static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
     32static NTSTATUS enum_groups_internal(struct winbindd_domain *domain,
    4733                                TALLOC_CTX *mem_ctx,
    4834                                uint32 *num_entries,
    49                                 struct acct_info **info)
    50 {
    51         /* We don't have domain groups */
    52         *num_entries = 0;
    53         *info = NULL;
    54         return NT_STATUS_OK;
    55 }
    56 
    57 /* List all domain groups */
    58 
    59 static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
    60                                 TALLOC_CTX *mem_ctx,
    61                                 uint32 *num_entries,
    62                                 struct acct_info **info)
     35                                struct acct_info **info,
     36                                enum lsa_SidType sidtype)
    6337{
    6438        struct pdb_search *search;
    65         struct samr_displayentry *aliases;
     39        struct samr_displayentry *entries;
    6640        int i;
    6741        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    6842
    69         search = pdb_search_aliases(&domain->sid);
     43        if (sidtype == SID_NAME_ALIAS) {
     44                search = pdb_search_aliases(&domain->sid);
     45        } else {
     46                search = pdb_search_groups();
     47        }
     48
    7049        if (search == NULL) goto done;
    7150
    72         *num_entries = pdb_search_entries(search, 0, 0xffffffff, &aliases);
    73         if (*num_entries == 0) goto done;
     51        *num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries);
     52        if (*num_entries == 0) {
     53                /* Zero entries isn't an error */
     54                result = NT_STATUS_OK;
     55                goto done;
     56        }
    7457
    7558        *info = TALLOC_ARRAY(mem_ctx, struct acct_info, *num_entries);
     
    8063
    8164        for (i=0; i<*num_entries; i++) {
    82                 fstrcpy((*info)[i].acct_name, aliases[i].account_name);
    83                 fstrcpy((*info)[i].acct_desc, aliases[i].description);
    84                 (*info)[i].rid = aliases[i].rid;
     65                fstrcpy((*info)[i].acct_name, entries[i].account_name);
     66                fstrcpy((*info)[i].acct_desc, entries[i].description);
     67                (*info)[i].rid = entries[i].rid;
    8568        }
    8669
     
    8972        pdb_search_destroy(search);
    9073        return result;
     74}
     75
     76/* List all local groups (aliases) */
     77static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
     78                                TALLOC_CTX *mem_ctx,
     79                                uint32 *num_entries,
     80                                struct acct_info **info)
     81{
     82        return enum_groups_internal(domain,
     83                                mem_ctx,
     84                                num_entries,
     85                                info,
     86                                SID_NAME_ALIAS);
    9187}
    9288
     
    144140static NTSTATUS rids_to_names(struct winbindd_domain *domain,
    145141                              TALLOC_CTX *mem_ctx,
    146                               const DOM_SID *sid,
     142                              const DOM_SID *domain_sid,
    147143                              uint32 *rids,
    148144                              size_t num_rids,
     
    151147                              enum lsa_SidType **types)
    152148{
    153         return NT_STATUS_UNSUCCESSFUL;
    154 }
    155 
    156 /* Lookup user information from a rid or username. */
    157 static NTSTATUS query_user(struct winbindd_domain *domain,
    158                            TALLOC_CTX *mem_ctx,
    159                            const DOM_SID *user_sid,
    160                            WINBIND_USERINFO *user_info)
    161 {
    162         return NT_STATUS_NO_SUCH_USER;
     149        size_t i;
     150        bool have_mapped;
     151        bool have_unmapped;
     152
     153        *domain_name = NULL;
     154        *names = NULL;
     155        *types = NULL;
     156
     157        if (!num_rids) {
     158                return NT_STATUS_OK;
     159        }
     160
     161        *names = TALLOC_ARRAY(mem_ctx, char *, num_rids);
     162        *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids);
     163
     164        if ((*names == NULL) || (*types == NULL)) {
     165                return NT_STATUS_NO_MEMORY;
     166        }
     167
     168        have_mapped = have_unmapped = false;
     169
     170        for (i=0; i<num_rids; i++) {
     171                DOM_SID sid;
     172                const char *dom = NULL, *nam = NULL;
     173                enum lsa_SidType type = SID_NAME_UNKNOWN;
     174
     175                if (!sid_compose(&sid, domain_sid, rids[i])) {
     176                        return NT_STATUS_INTERNAL_ERROR;
     177                }
     178
     179                if (!lookup_sid(mem_ctx, &sid, &dom, &nam, &type)) {
     180                        have_unmapped = true;
     181                        (*types)[i] = SID_NAME_UNKNOWN;
     182                        (*names)[i] = talloc_strdup(mem_ctx, "");
     183                } else {
     184                        have_mapped = true;
     185                        (*types)[i] = type;
     186                        (*names)[i] = CONST_DISCARD(char *, nam);
     187                }
     188
     189                if (domain_name == NULL) {
     190                        *domain_name = CONST_DISCARD(char *, dom);
     191                } else {
     192                        char *dname = CONST_DISCARD(char *, dom);
     193                        TALLOC_FREE(dname);
     194                }
     195        }
     196
     197        if (!have_mapped) {
     198                return NT_STATUS_NONE_MAPPED;
     199        }
     200        if (!have_unmapped) {
     201                return NT_STATUS_OK;
     202        }
     203        return STATUS_SOME_UNMAPPED;
    163204}
    164205
     
    179220        }
    180221
    181         if ( !pdb_getsampwsid( user, user_sid ) ) {
     222        if (!pdb_getsampwsid(user, user_sid ) ) {
    182223                return NT_STATUS_NO_SUCH_USER;
    183224        }
     
    208249}
    209250
    210 /* Lookup group membership given a rid.   */
    211 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
     251/* find the sequence number for a domain */
     252static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
     253{
     254        BOOL result;
     255        time_t seq_num;
     256
     257        result = pdb_get_seq_num(&seq_num);
     258        if (!result) {
     259                *seq = 1;
     260        }
     261
     262        *seq = (int) seq_num;
     263        /* *seq = 1; */
     264        return NT_STATUS_OK;
     265}
     266
     267static NTSTATUS lockout_policy(struct winbindd_domain *domain,
     268                               TALLOC_CTX *mem_ctx,
     269                               SAM_UNK_INFO_12 *policy)
     270{
     271        /* actually we have that */
     272        return NT_STATUS_NOT_IMPLEMENTED;
     273}
     274
     275static NTSTATUS password_policy(struct winbindd_domain *domain,
     276                                TALLOC_CTX *mem_ctx,
     277                                SAM_UNK_INFO_1 *policy)
     278{
     279        uint32 min_pass_len,pass_hist,password_properties;
     280        time_t u_expire, u_min_age;
     281        NTTIME nt_expire, nt_min_age;
     282        uint32 account_policy_temp;
     283
     284        if ((policy = TALLOC_ZERO_P(mem_ctx, SAM_UNK_INFO_1)) == NULL) {
     285                return NT_STATUS_NO_MEMORY;
     286        }
     287
     288        if (!pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp)) {
     289                return NT_STATUS_ACCESS_DENIED;
     290        }
     291        min_pass_len = account_policy_temp;
     292
     293        if (!pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp)) {
     294                return NT_STATUS_ACCESS_DENIED;
     295        }
     296        pass_hist = account_policy_temp;
     297
     298        if (!pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp)) {
     299                return NT_STATUS_ACCESS_DENIED;
     300        }
     301        password_properties = account_policy_temp;
     302
     303        if (!pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp)) {
     304                return NT_STATUS_ACCESS_DENIED;
     305        }
     306        u_expire = account_policy_temp;
     307
     308        if (!pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp)) {
     309                return NT_STATUS_ACCESS_DENIED;
     310        }
     311        u_min_age = account_policy_temp;
     312
     313        unix_to_nt_time_abs(&nt_expire, u_expire);
     314        unix_to_nt_time_abs(&nt_min_age, u_min_age);
     315
     316        init_unk_info1(policy, (uint16)min_pass_len, (uint16)pass_hist,
     317                       password_properties, nt_expire, nt_min_age);
     318
     319        return NT_STATUS_OK;
     320}
     321
     322/*********************************************************************
     323 BUILTIN specific functions.
     324*********************************************************************/
     325
     326/* list all domain groups */
     327static NTSTATUS builtin_enum_dom_groups(struct winbindd_domain *domain,
     328                                TALLOC_CTX *mem_ctx,
     329                                uint32 *num_entries,
     330                                struct acct_info **info)
     331{
     332        /* BUILTIN doesn't have domain groups */
     333        *num_entries = 0;
     334        *info = NULL;
     335        return NT_STATUS_OK;
     336}
     337
     338/* Query display info for a domain.  This returns enough information plus a
     339   bit extra to give an overview of domain users for the User Manager
     340   application. */
     341static NTSTATUS builtin_query_user_list(struct winbindd_domain *domain,
     342                               TALLOC_CTX *mem_ctx,
     343                               uint32 *num_entries,
     344                               WINBIND_USERINFO **info)
     345{
     346        /* We don't have users */
     347        *num_entries = 0;
     348        *info = NULL;
     349        return NT_STATUS_OK;
     350}
     351
     352/* Lookup user information from a rid or username. */
     353static NTSTATUS builtin_query_user(struct winbindd_domain *domain,
     354                           TALLOC_CTX *mem_ctx,
     355                           const DOM_SID *user_sid,
     356                           WINBIND_USERINFO *user_info)
     357{
     358        return NT_STATUS_NO_SUCH_USER;
     359}
     360
     361static NTSTATUS builtin_lookup_groupmem(struct winbindd_domain *domain,
    212362                                TALLOC_CTX *mem_ctx,
    213363                                const DOM_SID *group_sid, uint32 *num_names,
    214364                                DOM_SID **sid_mem, char ***names,
     365                                uint32 **name_types)
     366{
     367        *num_names = 0;
     368        *sid_mem = NULL;
     369        *names = NULL;
     370        *name_types = 0;
     371        return NT_STATUS_NO_SUCH_GROUP;
     372}
     373
     374/* get a list of trusted domains - builtin domain */
     375static NTSTATUS builtin_trusted_domains(struct winbindd_domain *domain,
     376                                TALLOC_CTX *mem_ctx,
     377                                uint32 *num_domains,
     378                                char ***names,
     379                                char ***alt_names,
     380                                DOM_SID **dom_sids)
     381{
     382        *num_domains = 0;
     383        *names = NULL;
     384        *alt_names = NULL;
     385        *dom_sids = NULL;
     386        return NT_STATUS_OK;
     387}
     388
     389/*********************************************************************
     390 SAM specific functions.
     391*********************************************************************/
     392
     393/* list all domain groups */
     394static NTSTATUS sam_enum_dom_groups(struct winbindd_domain *domain,
     395                                TALLOC_CTX *mem_ctx,
     396                                uint32 *num_entries,
     397                                struct acct_info **info)
     398{
     399        return enum_groups_internal(domain,
     400                                mem_ctx,
     401                                num_entries,
     402                                info,
     403                                SID_NAME_DOM_GRP);
     404}
     405
     406static NTSTATUS sam_query_user_list(struct winbindd_domain *domain,
     407                               TALLOC_CTX *mem_ctx,
     408                               uint32 *num_entries,
     409                               WINBIND_USERINFO **info)
     410{
     411        struct pdb_search *ps = pdb_search_users(ACB_NORMAL);
     412        struct samr_displayentry *entries = NULL;
     413        uint32 i;
     414
     415        *num_entries = 0;
     416        *info = NULL;
     417
     418        if (!ps) {
     419                return NT_STATUS_NO_MEMORY;
     420        }
     421
     422        *num_entries = pdb_search_entries(ps,
     423                                        1, 0xffffffff,
     424                                        &entries);
     425
     426        *info = TALLOC_ZERO_ARRAY(mem_ctx, WINBIND_USERINFO, *num_entries);
     427        if (!(*info)) {
     428                pdb_search_destroy(ps);
     429                return NT_STATUS_NO_MEMORY;
     430        }
     431
     432        for (i = 0; i < *num_entries; i++) {
     433                struct samr_displayentry *e = &entries[i];
     434
     435                (*info)[i].acct_name = talloc_strdup(mem_ctx, e->account_name );
     436                (*info)[i].full_name = talloc_strdup(mem_ctx, e->fullname );
     437                (*info)[i].homedir = NULL;
     438                (*info)[i].shell = NULL;
     439                sid_compose(&(*info)[i].user_sid, &domain->sid, e->rid);
     440
     441                /* For the moment we set the primary group for
     442                every user to be the Domain Users group.
     443                There are serious problems with determining
     444                the actual primary group for large domains.
     445                This should really be made into a 'winbind
     446                force group' smb.conf parameter or
     447                something like that. */
     448
     449                sid_compose(&(*info)[i].group_sid, &domain->sid,
     450                                DOMAIN_GROUP_RID_USERS);
     451        }
     452
     453        pdb_search_destroy(ps);
     454        return NT_STATUS_OK;
     455}
     456
     457/* Lookup user information from a rid or username. */
     458static NTSTATUS sam_query_user(struct winbindd_domain *domain,
     459                           TALLOC_CTX *mem_ctx,
     460                           const DOM_SID *user_sid,
     461                           WINBIND_USERINFO *user_info)
     462{
     463        struct samu *sampass = NULL;
     464        fstring sidstr;
     465
     466        ZERO_STRUCTP(user_info);
     467
     468        if (!sid_check_is_in_our_domain(user_sid)) {
     469                return NT_STATUS_NO_SUCH_USER;
     470        }
     471
     472        sid_to_string(sidstr, user_sid);
     473        DEBUG(10,("sam_query_user: getting samu info for sid %s\n",
     474                sidstr ));
     475
     476        if (!(sampass = samu_new(mem_ctx))) {
     477                return NT_STATUS_NO_MEMORY;
     478        }
     479
     480        if (!pdb_getsampwsid(sampass, user_sid)) {
     481                TALLOC_FREE(sampass);
     482                return NT_STATUS_NO_SUCH_USER;
     483        }
     484
     485        if (pdb_get_group_sid(sampass) == NULL) {
     486                TALLOC_FREE(sampass);
     487                return NT_STATUS_NO_SUCH_GROUP;
     488        }
     489
     490        sid_to_string(sidstr, sampass->group_sid);
     491        DEBUG(10,("sam_query_user: group sid %s\n", sidstr ));
     492
     493        sid_copy(&user_info->user_sid, user_sid);
     494        sid_copy(&user_info->group_sid, sampass->group_sid);
     495
     496        user_info->acct_name = talloc_strdup(mem_ctx, sampass->username ?
     497                                        sampass->username : "");
     498        user_info->full_name = talloc_strdup(mem_ctx, sampass->full_name ?
     499                                        sampass->full_name : "");
     500        user_info->homedir = talloc_strdup(mem_ctx, sampass->home_dir ?
     501                                        sampass->home_dir : "");
     502        if (sampass->unix_pw && sampass->unix_pw->pw_shell) {
     503                user_info->shell = talloc_strdup(mem_ctx, sampass->unix_pw->pw_shell);
     504        } else {
     505                user_info->shell = talloc_strdup(mem_ctx, "");
     506        }
     507        user_info->primary_gid = sampass->unix_pw ? sampass->unix_pw->pw_gid : (gid_t)-1;
     508
     509        TALLOC_FREE(sampass);
     510        return NT_STATUS_OK;
     511}
     512
     513/* Lookup group membership given a rid.   */
     514static NTSTATUS sam_lookup_groupmem(struct winbindd_domain *domain,
     515                                TALLOC_CTX *mem_ctx,
     516                                const DOM_SID *group_sid, uint32 *num_names,
     517                                DOM_SID **sid_mem, char ***names,
    215518                                uint32 **name_types)
    216519{
     
    304607}
    305608
    306 /* find the sequence number for a domain */
    307 static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
    308 {
    309         BOOL result;
    310         time_t seq_num;
    311 
    312         result = pdb_get_seq_num(&seq_num);
    313         if (!result) {
    314                 *seq = 1;
    315         }
    316 
    317         *seq = (int) seq_num;
    318         /* *seq = 1; */
    319         return NT_STATUS_OK;
    320 }
    321 
    322 static NTSTATUS lockout_policy(struct winbindd_domain *domain,
    323                                TALLOC_CTX *mem_ctx,
    324                                SAM_UNK_INFO_12 *policy)
    325 {
    326         /* actually we have that */
    327         return NT_STATUS_NOT_IMPLEMENTED;
    328 }
    329 
    330 static NTSTATUS password_policy(struct winbindd_domain *domain,
    331                                 TALLOC_CTX *mem_ctx,
    332                                 SAM_UNK_INFO_1 *policy)
    333 {
    334         uint32 min_pass_len,pass_hist,password_properties;
    335         time_t u_expire, u_min_age;
    336         NTTIME nt_expire, nt_min_age;
    337         uint32 account_policy_temp;
    338 
    339         if ((policy = TALLOC_ZERO_P(mem_ctx, SAM_UNK_INFO_1)) == NULL) {
    340                 return NT_STATUS_NO_MEMORY;
    341         }
    342 
    343         if (!pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp)) {
    344                 return NT_STATUS_ACCESS_DENIED;
    345         }
    346         min_pass_len = account_policy_temp;
    347 
    348         if (!pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp)) {
    349                 return NT_STATUS_ACCESS_DENIED;
    350         }
    351         pass_hist = account_policy_temp;
    352 
    353         if (!pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp)) {
    354                 return NT_STATUS_ACCESS_DENIED;
    355         }
    356         password_properties = account_policy_temp;
    357        
    358         if (!pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp)) {
    359                 return NT_STATUS_ACCESS_DENIED;
    360         }
    361         u_expire = account_policy_temp;
    362 
    363         if (!pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp)) {
    364                 return NT_STATUS_ACCESS_DENIED;
    365         }
    366         u_min_age = account_policy_temp;
    367 
    368         unix_to_nt_time_abs(&nt_expire, u_expire);
    369         unix_to_nt_time_abs(&nt_min_age, u_min_age);
    370 
    371         init_unk_info1(policy, (uint16)min_pass_len, (uint16)pass_hist,
    372                        password_properties, nt_expire, nt_min_age);
    373 
    374         return NT_STATUS_OK;
    375 }
    376 
    377 /* get a list of trusted domains */
    378 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
     609/* get a list of trusted domains - sam */
     610static NTSTATUS sam_trusted_domains(struct winbindd_domain *domain,
    379611                                TALLOC_CTX *mem_ctx,
    380612                                uint32 *num_domains,
     
    434666
    435667/* the rpc backend methods are exposed via this structure */
    436 struct winbindd_methods passdb_methods = {
    437         False,
    438         query_user_list,
    439         enum_dom_groups,
     668struct winbindd_methods builtin_passdb_methods = {
     669        false,
     670        builtin_query_user_list,
     671        builtin_enum_dom_groups,
    440672        enum_local_groups,
    441673        name_to_sid,
    442674        sid_to_name,
    443675        rids_to_names,
    444         query_user,
     676        builtin_query_user,
    445677        lookup_usergroups,
    446678        lookup_useraliases,
    447         lookup_groupmem,
     679        builtin_lookup_groupmem,
    448680        sequence_number,
    449681        lockout_policy,
    450682        password_policy,
    451         trusted_domains,
     683        builtin_trusted_domains,
    452684};
     685
     686/* the rpc backend methods are exposed via this structure */
     687struct winbindd_methods sam_passdb_methods = {
     688        false,
     689        sam_query_user_list,
     690        sam_enum_dom_groups,
     691        enum_local_groups,
     692        name_to_sid,
     693        sid_to_name,
     694        rids_to_names,
     695        sam_query_user,
     696        lookup_usergroups,
     697        lookup_useraliases,
     698        sam_lookup_groupmem,
     699        sequence_number,
     700        lockout_policy,
     701        password_policy,
     702        sam_trusted_domains,
     703};
  • branches/samba-3.0/source/nsswitch/winbindd_proto.h

    r134 r140  
    2020void request_finished_cont(void *private_data, BOOL success);
    2121void winbind_check_sighup(void);
    22 void winbind_check_sigterm(void);
     22void winbind_check_sigterm(bool in_parent);
    2323int main(int argc, char **argv, char **envp);
    2424
  • branches/samba-3.0/source/nsswitch/winbindd_util.c

    r124 r140  
    2929
    3030extern struct winbindd_methods cache_methods;
    31 extern struct winbindd_methods passdb_methods;
     31extern struct winbindd_methods builtin_passdb_methods;
     32extern struct winbindd_methods sam_passdb_methods;
    3233
    3334/**
     
    8485                return False;
    8586
     87        if ( IS_DC )
     88                return sid_check_is_builtin(sid);
     89
    8690        return (sid_check_is_domain(sid) || sid_check_is_builtin(sid));
    8791}
     
    9195        if (sid == NULL)
    9296                return False;
     97
     98        if ( IS_DC )
     99                return sid_check_is_in_builtin(sid);
    93100
    94101        return (sid_check_is_in_our_domain(sid) || sid_check_is_in_builtin(sid));
     
    141148        ZERO_STRUCTP(domain);
    142149
    143         /* prioritise the short name */
    144         if (strchr_m(domain_name, '.') && alternative_name && *alternative_name) {
    145                 fstrcpy(domain->name, alternative_name);
    146                 fstrcpy(domain->alt_name, domain_name);
    147         } else {
    148                 fstrcpy(domain->name, domain_name);
    149                 if (alternative_name) {
    150                         fstrcpy(domain->alt_name, alternative_name);
    151                 }
     150        fstrcpy(domain->name, domain_name);
     151        if (alternative_name) {
     152                fstrcpy(domain->alt_name, alternative_name);
    152153        }
    153154
     
    524525
    525526        domain = add_trusted_domain(get_global_sam_name(), NULL,
    526                                     &passdb_methods, get_global_sam_sid());
     527                                    &sam_passdb_methods, get_global_sam_sid());
    527528        if ( role != ROLE_DOMAIN_MEMBER ) {
    528529                domain->primary = True;
     
    532533        /* BUILTIN domain */
    533534
    534         domain = add_trusted_domain("BUILTIN", NULL, &passdb_methods,
     535        domain = add_trusted_domain("BUILTIN", NULL, &builtin_passdb_methods,
    535536                                    &global_sid_Builtin);
    536537        setup_domain_child(domain, &domain->child, NULL);
Note: See TracChangeset for help on using the changeset viewer.