diff --git a/modules/ldapbackend/exceptions.hh b/modules/ldapbackend/exceptions.hh index 3436e38d1824..2e7ca6f4bf6e 100644 --- a/modules/ldapbackend/exceptions.hh +++ b/modules/ldapbackend/exceptions.hh @@ -17,13 +17,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#pragma once + #include #include #include -#ifndef LDAPEXCEPTIONS_HH -#define LDAPEXCEPTIONS_HH - class LDAPException : public std::runtime_error { public: @@ -48,4 +47,3 @@ class LDAPNoSuchObject : public LDAPException explicit LDAPNoSuchObject() : LDAPException( "No such object" ) {} }; -#endif // LDAPEXCEPTIONS_HH diff --git a/modules/ldapbackend/ldapauthenticator.hh b/modules/ldapbackend/ldapauthenticator.hh index d8452a08b76e..53d22bed4a4d 100644 --- a/modules/ldapbackend/ldapauthenticator.hh +++ b/modules/ldapbackend/ldapauthenticator.hh @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#pragma once + #include #include @@ -23,9 +25,6 @@ #include #endif -#ifndef LDAPAUTHENTICATOR_HH -#define LDAPAUTHENTICATOR_HH - class LdapAuthenticator { public: @@ -34,4 +33,3 @@ class LdapAuthenticator virtual std::string getError() const = 0; }; -#endif // LDAPAUTHENTICATOR_HH diff --git a/modules/ldapbackend/ldapauthenticator_p.hh b/modules/ldapbackend/ldapauthenticator_p.hh index cd5d083eed9e..5cf8d412008a 100644 --- a/modules/ldapbackend/ldapauthenticator_p.hh +++ b/modules/ldapbackend/ldapauthenticator_p.hh @@ -16,12 +16,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#pragma once + #include #include "ldapauthenticator.hh" -#ifndef LDAPAUTHENTICATOR_P_HH -#define LDAPAUTHENTICATOR_P_HH - #ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS #define krb5_get_init_creds_opt_set_default_flags( a, b, c, d ) /* This does not exist with MIT Kerberos */ #endif @@ -69,4 +68,3 @@ class LdapGssapiAuthenticator : public LdapAuthenticator virtual std::string getError() const; }; -#endif // LDAPAUTHENTICATOR_P_HH diff --git a/modules/ldapbackend/ldapbackend.hh b/modules/ldapbackend/ldapbackend.hh index f89e29af22d2..e0589ff2aa54 100644 --- a/modules/ldapbackend/ldapbackend.hh +++ b/modules/ldapbackend/ldapbackend.hh @@ -20,6 +20,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +#pragma once + #include #include #include @@ -39,10 +42,6 @@ #include "utils.hh" - -#ifndef LDAPBACKEND_HH -#define LDAPBACKEND_HH - using std::string; using std::vector; @@ -184,4 +183,3 @@ class LdapBackend : public DNSBackend void setNotified( uint32_t id, uint32_t serial ) override; }; -#endif /* LDAPBACKEND_HH */ diff --git a/modules/ldapbackend/ldaputils.hh b/modules/ldapbackend/ldaputils.hh index 83012f234f72..5b1bc7a21849 100644 --- a/modules/ldapbackend/ldaputils.hh +++ b/modules/ldapbackend/ldaputils.hh @@ -17,14 +17,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#pragma once + #include "exceptions.hh" #include #include -#ifndef LDAPUTILS_HH -#define LDAPUTILS_HH - void ldapSetOption( LDAP *conn, int option, void *value ); void ldapGetOption( LDAP *conn, int option, void *value ); @@ -33,4 +32,3 @@ std::string ldapGetError( LDAP *conn, int code ); int ldapWaitResult( LDAP *conn, int msgid, int timeout, LDAPMessage** result = NULL ); -#endif // LDAPUTILS_HH diff --git a/modules/ldapbackend/powerldap.hh b/modules/ldapbackend/powerldap.hh index 8ff3441df306..4c7e8ff2c06c 100644 --- a/modules/ldapbackend/powerldap.hh +++ b/modules/ldapbackend/powerldap.hh @@ -20,6 +20,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#pragma once + #include #include #include @@ -31,12 +33,6 @@ #include #include - - - -#ifndef POWERLDAP_HH -#define POWERLDAP_HH - using std::list; using std::map; using std::string; @@ -100,6 +96,3 @@ class PowerLDAP static const string escape( const string& tobe ); }; - - -#endif diff --git a/modules/ldapbackend/utils.hh b/modules/ldapbackend/utils.hh index 902c3d53251d..7fc99fbb7e77 100644 --- a/modules/ldapbackend/utils.hh +++ b/modules/ldapbackend/utils.hh @@ -19,6 +19,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +#pragma once + #include #include #include @@ -26,10 +29,6 @@ #include "pdns/misc.hh" #include "pdns/utility.hh" - -#ifndef LDAPBACKEND_UTILS_HH -#define LDAPBACKEND_UTILS_HH - using std::string; using std::vector; @@ -174,4 +173,3 @@ inline time_t str2tstamp( const string& str ) return 0; } -#endif diff --git a/pdns/misc.cc b/pdns/misc.cc index ab2ea0c6869b..c44d674be90c 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -197,10 +197,11 @@ size_t writen2WithTimeout(int fd, const void * buffer, size_t len, int timeout) string nowTime() { time_t now = time(nullptr); - struct tm* tm = localtime(&now); + struct tm tm; + localtime_r(&now, &tm); char buffer[30]; // YYYY-mm-dd HH:MM:SS TZOFF - strftime(buffer, sizeof(buffer), "%F %T %z", tm); + strftime(buffer, sizeof(buffer), "%F %T %z", &tm); buffer[sizeof(buffer)-1] = '\0'; return string(buffer); } diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 7e2c548d7744..627c467fcc07 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -414,7 +414,8 @@ uint64_t SyncRes::doEDNSDump(int fd) fprintf(fp.get(),"; edns from thread follows\n;\n"); for(const auto& eds : t_sstorage.ednsstatus) { count++; - fprintf(fp.get(), "%s\t%d\t%s", eds.first.toString().c_str(), (int)eds.second.mode, ctime(&eds.second.modeSetAt)); + char tmp[26]; + fprintf(fp.get(), "%s\t%d\t%s", eds.first.toString().c_str(), (int)eds.second.mode, ctime_r(&eds.second.modeSetAt, tmp)); } return count; } @@ -456,8 +457,9 @@ uint64_t SyncRes::doDumpThrottleMap(int fd) for(const auto& i : throttleMap) { count++; + char tmp[26]; // remote IP, dns name, qtype, count, ttd - fprintf(fp.get(), "%s\t%s\t%d\t%u\t%s", i.first.get<0>().toString().c_str(), i.first.get<1>().toLogString().c_str(), i.first.get<2>(), i.second.count, ctime(&i.second.ttd)); + fprintf(fp.get(), "%s\t%s\t%d\t%u\t%s", i.first.get<0>().toString().c_str(), i.first.get<1>().toLogString().c_str(), i.first.get<2>(), i.second.count, ctime_r(&i.second.ttd, tmp)); } return count; diff --git a/pdns/tsigutils.hh b/pdns/tsigutils.hh index bffd0971d73f..3b5c926651d9 100644 --- a/pdns/tsigutils.hh +++ b/pdns/tsigutils.hh @@ -20,7 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#pragma once + #include "dnsname.hh" #include std::string makeTSIGKey(const DNSName& algorithm); +