source: npl/system/nss_ldap/patches/log_authpriv.patch

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[c5c522c]1Description: use LOG_AUTHPRIV facility with syslog() calls
2Author: Stephen Frost <sfrost@debian.org>
3Bug-Debian: http://bugs.debian.org/310421
4
5--- a/ldap-nss.c
6+++ b/ldap-nss.c
7@@ -698,7 +698,7 @@ do_close (void)
8 # else
9       sd = __session.ls_conn->ld_sb.sb_sd;
10 # endif /* LDAP_OPT_DESC */
11-      syslog (LOG_INFO, "nss_ldap: closing connection %p fd %d",
12+      syslog (LOG_AUTHPRIV | LOG_INFO, "nss_ldap: closing connection %p fd %d",
13              __session.ls_conn, sd);
14 #endif /* DEBUG */
15 
16@@ -990,7 +990,7 @@ do_close_no_unbind (void)
17   closeSd = do_get_our_socket (&sd);
18 
19 #if defined(DEBUG) || defined(DEBUG_SOCKETS)
20-  syslog (LOG_INFO, "nss_ldap: %sclosing connection (no unbind) %p fd %d",
21+  syslog (LOG_AUTHPRIV | LOG_INFO, "nss_ldap: %sclosing connection (no unbind) %p fd %d",
22          closeSd ? "" : "not ", __session.ls_conn, sd);
23 #endif /* DEBUG */
24 
25@@ -1152,11 +1152,11 @@ do_init (void)
26 
27 #ifdef DEBUG
28 #ifdef HAVE_PTHREAD_ATFORK
29-  syslog (LOG_DEBUG,
30+  syslog (LOG_AUTHPRIV | LOG_DEBUG,
31          "nss_ldap: __session.ls_state=%d, __session.ls_conn=%p, __euid=%i, euid=%i",
32          __session.ls_state, __session.ls_conn, __euid, euid);
33 #elif defined(HAVE_LIBC_LOCK_H) || defined(HAVE_BITS_LIBC_LOCK_H)
34-  syslog (LOG_DEBUG,
35+  syslog (LOG_AUTHPRIV | LOG_DEBUG,
36          "nss_ldap: libpthreads=%s, __session.ls_state=%d, __session.ls_conn=%p, __pid=%i, pid=%i, __euid=%i, euid=%i",
37          ((__pthread_once == NULL || __pthread_atfork == NULL) ? "FALSE" : "TRUE"),
38          __session.ls_state,
39@@ -1164,7 +1164,7 @@ do_init (void)
40          ((__pthread_once == NULL || __pthread_atfork == NULL) ? __pid : -1),
41          ((__pthread_once == NULL || __pthread_atfork == NULL) ? pid : -1), __euid, euid);
42 #else
43-  syslog (LOG_DEBUG,
44+  syslog (LOG_AUTHPRIV | LOG_DEBUG,
45          "nss_ldap: __session.ls_state=%d, __session.ls_conn=%p, __pid=%i, pid=%i, __euid=%i, euid=%i",
46          __session.ls_state, __session.ls_conn, __pid, pid, __euid, euid);
47 #endif
48@@ -1275,7 +1275,7 @@ do_init (void)
49          stat = _nss_ldap_mergeconfigfromdns (__config, &configbufp, &configbuflen);
50          if (stat != NSS_SUCCESS)
51            {
52-             syslog (LOG_ERR, "nss_ldap: could not determine LDAP server from ldap.conf or DNS");
53+             syslog (LOG_AUTHPRIV | LOG_ERR, "nss_ldap: could not determine LDAP server from ldap.conf or DNS");
54            }
55        }
56 
57@@ -1418,7 +1418,7 @@ do_start_tls (ldap_session_t * session)
58           rc = LDAP_TIMEOUT;
59         }
60 
61-      syslog (LOG_INFO, "nss_ldap: ldap_start_tls failed: %s", ldap_err2string (rc));
62+      syslog (LOG_AUTHPRIV | LOG_INFO, "nss_ldap: ldap_start_tls failed: %s", ldap_err2string (rc));
63       debug ("<== do_start_tls (ldap_start_tls failed: %s)", ldap_err2string (rc));
64       return rc;
65     }
66@@ -1671,7 +1671,7 @@ do_open (void)
67   if (rc != LDAP_SUCCESS)
68     {
69       /* log actual LDAP error code */
70-      syslog (LOG_INFO,
71+      syslog (LOG_AUTHPRIV | LOG_INFO,
72              "nss_ldap: failed to bind to LDAP server %s: %s",
73              cfg->ldc_uris[__session.ls_current_uri],
74              ldap_err2string (rc));
75@@ -1829,6 +1829,9 @@ do_bind (LDAP * ld, int timelimit, const
76 #else
77          rc = ld->ld_errno;
78 #endif /* LDAP_OPT_ERROR_NUMBER */
79+         /* Notify if we failed. */
80+         syslog (LOG_AUTHPRIV | LOG_ERR, "nss_ldap: could not connect to any LDAP server as %s - %s",
81+                         dn, ldap_err2string (rc));
82          debug ("<== do_bind");
83 
84          return rc;
85@@ -2481,7 +2484,7 @@ do_result (ent_context_t * ctx, int all)
86 #else
87          rc = __session.ls_conn->ld_errno;
88 #endif /* LDAP_OPT_ERROR_NUMBER */
89-         syslog (LOG_ERR, "nss_ldap: could not get LDAP result - %s",
90+         syslog (LOG_AUTHPRIV | LOG_ERR, "nss_ldap: could not get LDAP result - %s",
91                  ldap_err2string (rc));
92          do_close();
93          stat = NSS_UNAVAIL;
94@@ -2515,7 +2518,7 @@ do_result (ent_context_t * ctx, int all)
95                  && parserc != LDAP_MORE_RESULTS_TO_RETURN)
96                {
97                  ldap_abandon (__session.ls_conn, ctx->ec_msgid);
98-                 syslog (LOG_ERR,
99+                 syslog (LOG_AUTHPRIV | LOG_ERR,
100                          "nss_ldap: could not get LDAP result - %s",
101                          ldap_err2string (rc));
102                  do_close();
103@@ -2591,15 +2594,15 @@ do_with_reconnect (const char *base, int
104          else if (backoff < __session.ls_config->ldc_reconnect_maxsleeptime)
105            backoff *= 2;
106 
107-         syslog (LOG_INFO,
108+         syslog (LOG_AUTHPRIV | LOG_INFO,
109                  "nss_ldap: reconnecting to LDAP server (sleeping %d seconds)...",
110                  backoff);
111          (void) sleep (backoff);
112        }
113-      else if (tries > 1)
114+      else if (tries > 0)
115        {
116          /* Don't sleep, reconnect immediately. */
117-         syslog (LOG_INFO, "nss_ldap: reconnecting to LDAP server...");
118+         syslog (LOG_AUTHPRIV | LOG_INFO, "nss_ldap: reconnecting to LDAP server...");
119        }
120 
121       /* For each "try", attempt to connect to all specified URIs */
122@@ -2650,11 +2653,11 @@ do_with_reconnect (const char *base, int
123   switch (stat)
124     {
125     case NSS_UNAVAIL:
126-      syslog (LOG_ERR, "nss_ldap: could not search LDAP server - %s",
127+      syslog (LOG_AUTHPRIV | LOG_ERR, "nss_ldap: could not search LDAP server - %s",
128              ldap_err2string (rc));
129       break;
130     case NSS_TRYAGAIN:
131-      syslog (LOG_ERR,
132+      syslog (LOG_AUTHPRIV | LOG_ERR,
133              "nss_ldap: could not %s %sconnect to LDAP server - %s",
134              hard ? "hard" : "soft", tries ? "re" : "",
135              ldap_err2string (rc));
136@@ -2669,11 +2672,11 @@ do_with_reconnect (const char *base, int
137            uri = "(null)";
138 
139          if (tries)
140-           syslog (LOG_INFO,
141+           syslog (LOG_AUTHPRIV | LOG_INFO,
142              "nss_ldap: reconnected to LDAP server %s after %d attempt%s",
143              uri, tries, (tries == 1) ? "" : "s");
144          else
145-           syslog (LOG_INFO, "nss_ldap: reconnected to LDAP server %s", uri);
146+           syslog (LOG_AUTHPRIV | LOG_INFO, "nss_ldap: reconnected to LDAP server %s", uri);
147        }
148       time (&__session.ls_timestamp);
149       break;
150--- a/ldap-nss.h
151+++ b/ldap-nss.h
152@@ -140,9 +140,9 @@
153 #ifdef DEBUG
154 #ifdef DEBUG_SYSLOG
155 #ifdef HAVE_NSSWITCH_H
156-#define debug(fmt, args...) syslog(LOG_DEBUG, "nss_ldap: %s:%d thread %u - " fmt, __FILE__, __LINE__, thr_self() , ## args)
157+#define debug(fmt, args...) syslog(LOG_AUTHPRIV | LOG_DEBUG, "nss_ldap: %s:%d thread %u - " fmt, __FILE__, __LINE__, thr_self() , ## args)
158 #else
159-#define debug(fmt, args...) syslog(LOG_DEBUG, "nss_ldap: %s:%d thread %u - " fmt, __FILE__, __LINE__, pthread_self() , ## args)
160+#define debug(fmt, args...) syslog(LOG_AUTHPRIV | LOG_DEBUG, "nss_ldap: %s:%d thread %u - " fmt, __FILE__, __LINE__, pthread_self() , ## args)
161 #endif /* HAVE_NSSWITCH_H */
162 #else
163 #ifndef __GNUC__
Note: See TracBrowser for help on using the repository browser.