Author: jra
Date: 2005-12-19 18:51:36 +0000 (Mon, 19 Dec 2005)
New Revision: 12365

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12365

Log:
Fix up a couple of %d time_t arg warnings.
Remove local lookups from lookup name and sid, trust local LSA...
Jeremy.

Modified:
   trunk/source/nsswitch/winbindd_dual.c
   trunk/source/nsswitch/winbindd_pam.c
   trunk/source/utils/netlookup.c


Changeset:
Modified: trunk/source/nsswitch/winbindd_dual.c
===================================================================
--- trunk/source/nsswitch/winbindd_dual.c       2005-12-19 17:10:18 UTC (rev 
12364)
+++ trunk/source/nsswitch/winbindd_dual.c       2005-12-19 18:51:36 UTC (rev 
12365)
@@ -520,7 +520,7 @@
 
                tp = get_timed_events_timeout(&t, (time_t)-1);
                if (tp) {
-                       DEBUG(11,("select will use timeout of %d seconds\n", 
tp->tv_sec));
+                       DEBUG(11,("select will use timeout of %d seconds\n", 
(int)tp->tv_sec));
                }
 
                FD_ZERO(&read_fds);

Modified: trunk/source/nsswitch/winbindd_pam.c
===================================================================
--- trunk/source/nsswitch/winbindd_pam.c        2005-12-19 17:10:18 UTC (rev 
12364)
+++ trunk/source/nsswitch/winbindd_pam.c        2005-12-19 18:51:36 UTC (rev 
12365)
@@ -514,8 +514,8 @@
        /* does http_timestring use heimdals libroken strftime?? - Guenther */
        DEBUG(10,("got TGT for %s in %s (valid until: %s (%d), renewable till: 
%s (%d))\n", 
                principal_s, cc, 
-               http_timestring(ticket_lifetime), ticket_lifetime, 
-               http_timestring(renewal_until), renewal_until));
+               http_timestring(ticket_lifetime), (int)ticket_lifetime, 
+               http_timestring(renewal_until), (int)renewal_until));
 
        client_princ = talloc_strdup(state->mem_ctx, global_myname());
        if (client_princ == NULL) {

Modified: trunk/source/utils/netlookup.c
===================================================================
--- trunk/source/utils/netlookup.c      2005-12-19 17:10:18 UTC (rev 12364)
+++ trunk/source/utils/netlookup.c      2005-12-19 18:51:36 UTC (rev 12365)
@@ -122,13 +122,16 @@
 
 /********************************************************
  Do a lookup_sids call to localhost.
+ Check if the local machine is authoritative for this sid. We can't
+ check if this is our SID as that's stored in the root-read-only
+ secrets.tdb.
+ The local smbd will also ask winbindd for us, so we don't have to.
 ********************************************************/
 
-static BOOL lookup_name_from_sid_via_localhost(TALLOC_CTX *ctx,
-                                               DOM_SID *psid,
-                                               const char **ppdomain,
-                                               const char **ppname,
-                                               uint32 *ptype)
+BOOL net_lookup_name_from_sid(TALLOC_CTX *ctx,
+                               DOM_SID *psid,
+                               const char **ppdomain,
+                               const char **ppname)
 {
        NTSTATUS nt_status;
        struct con_struct *csp = NULL;
@@ -138,7 +141,6 @@
 
        *ppdomain = NULL;
        *ppname = NULL;
-       *ptype = (uint32)SID_NAME_UNKNOWN;
 
        csp = create_cs(ctx);
        if (csp == NULL) {
@@ -158,78 +160,41 @@
 
        *ppdomain = domains[0];
        *ppname = names[0];
-       *ptype = types[0];
-       
+       /* Don't care about type here. */
+
         /* Converted OK */
         return True;
 }
 
 /********************************************************
- Do a lookup_sids call to winbindd.
+ Do a lookup_names call to localhost.
 ********************************************************/
 
-static BOOL lookup_name_from_sid_via_winbind(TALLOC_CTX *ctx,
-                                               DOM_SID *psid,
-                                               const char **ppdomain,
-                                               const char **ppname)
+BOOL net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SID 
*pret_sid)
 {
-       struct winbindd_request request;
-       struct winbindd_response response;
+       NTSTATUS nt_status;
+       struct con_struct *csp = NULL;
+       DOM_SID *sids = NULL;
+       uint32 *types = NULL;
 
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
-       sid_to_string(request.data.sid, psid);
-
-       if (winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response) 
!= NSS_STATUS_SUCCESS) {
-                DEBUG(2, ("lookup_name_from_sid_via_winbind could not resolve 
%s\n", request.data.sid));
-                return False;
-        }
-
-       *ppdomain = talloc_strdup(ctx, response.data.name.dom_name);
-       *ppname = talloc_strdup(ctx, response.data.name.name);
-
-       return True;
-}
-
-/********************************************************
- The generic lookup name from sid call for net.
-********************************************************/
-
-BOOL net_lookup_name_from_sid(TALLOC_CTX *ctx, DOM_SID *psid, const char 
**ppdomain, const char **ppname)
-{
-       uint32 sidtype;
-
-       /* Check if local and we don't need to look up ... */
-       if (lookup_wellknown_sid(ctx, psid, ppdomain, ppname)) {
-               return True;
+       csp = create_cs(ctx);
+       if (csp == NULL) {
+               return False;
        }
 
-       /* Check if the local machine is authoritative for this sid. We can't
-          check if this is our SID as that's stored in the root-read-only
-          secrets.tdb. */
+       nt_status = rpccli_lsa_lookup_names(csp->lsapipe, ctx,
+                                               &csp->pol,
+                                               1,
+                                               &full_name,
+                                               &sids,
+                                               &types);
 
-       if (lookup_name_from_sid_via_localhost(ctx, psid, ppdomain, ppname, 
&sidtype)) {
-               /* Cache here.... */
-               return True;
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               return False;
        }
 
-       /* Finally it may be a trusted domain sid, ask winbindd. */
+       *pret_sid = sids[0];
 
-       if (lookup_name_from_sid_via_winbind(ctx, psid, ppdomain, ppname)) {
-               /* Cache here.... */
-               return True;
-       }
-
-       /* Can't map SID to name */
-       return False;
+        /* Converted OK */
+        return True;
 }
-
-/********************************************************
- The generic lookup sid from name call for net.
-********************************************************/
-
-BOOL net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *domain, const char 
*name, DOM_SID *pret_sid)
-{
-       return False;
-}

Reply via email to