diff options
Diffstat (limited to 'src/backend/libpq')
-rw-r--r-- | src/backend/libpq/auth.c | 45 | ||||
-rw-r--r-- | src/backend/libpq/be-fsstubs.c | 14 | ||||
-rw-r--r-- | src/backend/libpq/crypt.c | 4 | ||||
-rw-r--r-- | src/backend/libpq/password.c | 10 | ||||
-rw-r--r-- | src/backend/libpq/pqcomm.c | 55 | ||||
-rw-r--r-- | src/backend/libpq/pqpacket.c | 6 | ||||
-rw-r--r-- | src/backend/libpq/pqsignal.c | 9 |
7 files changed, 76 insertions, 67 deletions
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index d91fa9a8220..dcb702e9596 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.51 2001/01/24 19:42:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.52 2001/03/22 03:59:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ static int map_old_to_new(Port *port, UserAuth old, int status); static void auth_failed(Port *port); -char * pg_krb_server_keyfile; +char *pg_krb_server_keyfile; #ifdef KRB4 @@ -177,7 +177,7 @@ pg_an_to_ln(char *aname) * Various krb5 state which is not connection specfic, and a flag to * indicate whether we have initialised it yet. */ -static int pg_krb5_initialised; +static int pg_krb5_initialised; static krb5_context pg_krb5_context; static krb5_keytab pg_krb5_keytab; static krb5_principal pg_krb5_server; @@ -192,7 +192,8 @@ pg_krb5_init(void) return STATUS_OK; retval = krb5_init_context(&pg_krb5_context); - if (retval) { + if (retval) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pg_krb5_init: krb5_init_context returned" " Kerberos error %d\n", retval); @@ -201,23 +202,25 @@ pg_krb5_init(void) } retval = krb5_kt_resolve(pg_krb5_context, pg_krb_server_keyfile, &pg_krb5_keytab); - if (retval) { + if (retval) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pg_krb5_init: krb5_kt_resolve returned" " Kerberos error %d\n", retval); - com_err("postgres", retval, "while resolving keytab file %s", + com_err("postgres", retval, "while resolving keytab file %s", pg_krb_server_keyfile); krb5_free_context(pg_krb5_context); return STATUS_ERROR; } - retval = krb5_sname_to_principal(pg_krb5_context, NULL, PG_KRB_SRVNAM, + retval = krb5_sname_to_principal(pg_krb5_context, NULL, PG_KRB_SRVNAM, KRB5_NT_SRV_HST, &pg_krb5_server); - if (retval) { + if (retval) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pg_krb5_init: krb5_sname_to_principal returned" " Kerberos error %d\n", retval); - com_err("postgres", retval, + com_err("postgres", retval, "while getting server principal for service %s", pg_krb_server_keyfile); krb5_kt_close(pg_krb5_context, pg_krb5_keytab); @@ -245,25 +248,26 @@ static int pg_krb5_recvauth(Port *port) { krb5_error_code retval; - int ret; + int ret; krb5_auth_context auth_context = NULL; krb5_ticket *ticket; - char *kusername; + char *kusername; ret = pg_krb5_init(); if (ret != STATUS_OK) return ret; retval = krb5_recvauth(pg_krb5_context, &auth_context, - (krb5_pointer)&port->sock, PG_KRB_SRVNAM, + (krb5_pointer) & port->sock, PG_KRB_SRVNAM, pg_krb5_server, 0, pg_krb5_keytab, &ticket); - if (retval) { + if (retval) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pg_krb5_recvauth: krb5_recvauth returned" " Kerberos error %d\n", retval); - com_err("postgres", retval, "from krb5_recvauth"); + com_err("postgres", retval, "from krb5_recvauth"); return STATUS_ERROR; - } + } /* * The "client" structure comes out of the ticket and is therefore @@ -272,13 +276,14 @@ pg_krb5_recvauth(Port *port) * * I have no idea why this is considered necessary. */ - retval = krb5_unparse_name(pg_krb5_context, + retval = krb5_unparse_name(pg_krb5_context, ticket->enc_part2->client, &kusername); - if (retval) { + if (retval) + { snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pg_krb5_recvauth: krb5_unparse_name returned" " Kerberos error %d\n", retval); - com_err("postgres", retval, "while unparsing client name"); + com_err("postgres", retval, "while unparsing client name"); krb5_free_ticket(pg_krb5_context, ticket); krb5_auth_con_free(pg_krb5_context, auth_context); return STATUS_ERROR; @@ -288,13 +293,13 @@ pg_krb5_recvauth(Port *port) if (strncmp(port->user, kusername, SM_USER)) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "pg_krb5_recvauth: user name \"%s\" != krb5 name \"%s\"\n", + "pg_krb5_recvauth: user name \"%s\" != krb5 name \"%s\"\n", port->user, kusername); ret = STATUS_ERROR; } else ret = STATUS_OK; - + krb5_free_ticket(pg_krb5_context, ticket); krb5_auth_con_free(pg_krb5_context, auth_context); free(kusername); diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index 1d5870e93f4..4d50ee1ae12 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.57 2001/01/24 19:42:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.58 2001/03/22 03:59:30 momjian Exp $ * * NOTES * This should be moved to a more appropriate place. It is here @@ -60,7 +60,7 @@ * entries, of which any unused entries will be NULL. */ static LargeObjectDesc **cookies = NULL; -static int cookies_size = 0; +static int cookies_size = 0; static MemoryContext fscxt = NULL; @@ -329,10 +329,10 @@ loread(PG_FUNCTION_ARGS) Datum lowrite(PG_FUNCTION_ARGS) { - int32 fd = PG_GETARG_INT32(0); + int32 fd = PG_GETARG_INT32(0); struct varlena *wbuf = PG_GETARG_VARLENA_P(1); - int bytestowrite; - int totalwritten; + int bytestowrite; + int totalwritten; bytestowrite = VARSIZE(wbuf) - VARHDRSZ; totalwritten = lo_write(fd, VARDATA(wbuf), bytestowrite); @@ -371,7 +371,7 @@ lo_import(PG_FUNCTION_ARGS) */ nbytes = VARSIZE(filename) - VARHDRSZ; if (nbytes >= MAXPGPATH) - nbytes = MAXPGPATH-1; + nbytes = MAXPGPATH - 1; memcpy(fnamebuf, VARDATA(filename), nbytes); fnamebuf[nbytes] = '\0'; fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, 0666); @@ -445,7 +445,7 @@ lo_export(PG_FUNCTION_ARGS) */ nbytes = VARSIZE(filename) - VARHDRSZ; if (nbytes >= MAXPGPATH) - nbytes = MAXPGPATH-1; + nbytes = MAXPGPATH - 1; memcpy(fnamebuf, VARDATA(filename), nbytes); fnamebuf[nbytes] = '\0'; oumask = umask((mode_t) 0022); diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 325056ab1ef..59aef0d514d 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -9,7 +9,7 @@ * Dec 17, 1997 - Todd A. Brandys * Orignal Version Completed. * - * $Id: crypt.c,v 1.30 2001/02/07 23:31:38 tgl Exp $ + * $Id: crypt.c,v 1.31 2001/03/22 03:59:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -295,7 +295,7 @@ crypt_verify(const Port *port, const char *user, const char *pgpass) vuntil = INVALID_ABSTIME; else vuntil = DatumGetAbsoluteTime(DirectFunctionCall1(nabstimein, - CStringGetDatum(valuntil))); + CStringGetDatum(valuntil))); current = GetCurrentAbsoluteTime(); if (vuntil != INVALID_ABSTIME && vuntil < current) retval = STATUS_ERROR; diff --git a/src/backend/libpq/password.c b/src/backend/libpq/password.c index 856c3028800..77b09be18a4 100644 --- a/src/backend/libpq/password.c +++ b/src/backend/libpq/password.c @@ -2,7 +2,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: password.c,v 1.35 2001/01/24 19:42:56 momjian Exp $ + * $Id: password.c,v 1.36 2001/03/22 03:59:30 momjian Exp $ * */ @@ -37,7 +37,7 @@ verify_password(const Port *port, const char *user, const char *password) if (!pw_file) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "verify_password: Unable to open password file \"%s\": %s\n", + "verify_password: Unable to open password file \"%s\": %s\n", pw_file_fullname, strerror(errno)); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); @@ -77,12 +77,12 @@ verify_password(const Port *port, const char *user, const char *password) /* * If the password is empty of "+" then we use the regular - * pg_shadow passwords. If we use crypt then we have to - * use pg_shadow passwords no matter what. + * pg_shadow passwords. If we use crypt then we have to use + * pg_shadow passwords no matter what. */ if (port->auth_method == uaCrypt || test_pw == NULL || test_pw[0] == '\0' - || strcmp(test_pw, "+")==0) + || strcmp(test_pw, "+") == 0) return crypt_verify(port, user, password); if (strcmp(crypt(password, test_pw), test_pw) == 0) diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 7a20d66f7e1..e3250862363 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -29,7 +29,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqcomm.c,v 1.116 2001/01/24 19:42:56 momjian Exp $ + * $Id: pqcomm.c,v 1.117 2001/03/22 03:59:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,7 +71,7 @@ #include <netdb.h> #include <netinet/in.h> #ifdef HAVE_NETINET_TCP_H -# include <netinet/tcp.h> +#include <netinet/tcp.h> #endif #include <arpa/inet.h> #include <sys/file.h> @@ -91,8 +91,8 @@ static void pq_close(void); /* * Configuration options */ -int Unix_socket_permissions; -char * Unix_socket_group; +int Unix_socket_permissions; +char *Unix_socket_group; /* @@ -223,47 +223,49 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, UNIXSOCK_PATH(saddr.un, portNumber, unixSocketName); len = UNIXSOCK_LEN(saddr.un); strcpy(sock_path, saddr.un.sun_path); + /* * Grab an interlock file associated with the socket file. */ - if (! CreateSocketLockFile(sock_path, true)) + if (!CreateSocketLockFile(sock_path, true)) return STATUS_ERROR; + /* - * Once we have the interlock, we can safely delete any pre-existing - * socket file to avoid failure at bind() time. + * Once we have the interlock, we can safely delete any + * pre-existing socket file to avoid failure at bind() time. */ unlink(sock_path); } -#endif /* HAVE_UNIX_SOCKETS */ +#endif /* HAVE_UNIX_SOCKETS */ - if (family == AF_INET) - { + if (family == AF_INET) + { /* TCP/IP socket */ if (hostName[0] == '\0') - saddr.in.sin_addr.s_addr = htonl(INADDR_ANY); + saddr.in.sin_addr.s_addr = htonl(INADDR_ANY); else - { + { struct hostent *hp; - + hp = gethostbyname(hostName); if ((hp == NULL) || (hp->h_addrtype != AF_INET)) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "FATAL: StreamServerPort: gethostbyname(%s) failed\n", - hostName); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); + "FATAL: StreamServerPort: gethostbyname(%s) failed\n", + hostName); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); return STATUS_ERROR; } memmove((char *) &(saddr.in.sin_addr), (char *) hp->h_addr, hp->h_length); } - + saddr.in.sin_port = htons(portNumber); len = sizeof(struct sockaddr_in); } - err = bind(fd, (struct sockaddr *)&saddr.sa, len); + err = bind(fd, (struct sockaddr *) & saddr.sa, len); if (err < 0) { snprintf(PQerrormsg, PQERRORMSG_LENGTH, @@ -291,16 +293,16 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, on_proc_exit(StreamDoUnlink, 0); /* - * Fix socket ownership/permission if requested. Note we must - * do this before we listen() to avoid a window where unwanted + * Fix socket ownership/permission if requested. Note we must do + * this before we listen() to avoid a window where unwanted * connections could get accepted. */ Assert(Unix_socket_group); if (Unix_socket_group[0] != '\0') { - char *endptr; + char *endptr; unsigned long int val; - gid_t gid; + gid_t gid; val = strtoul(Unix_socket_group, &endptr, 10); if (*endptr == '\0') @@ -346,7 +348,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, return STATUS_ERROR; } } -#endif /* HAVE_UNIX_SOCKETS */ +#endif /* HAVE_UNIX_SOCKETS */ listen(fd, SOMAXCONN); @@ -385,9 +387,10 @@ StreamConnection(int server_fd, Port *port) } #ifdef SCO_ACCEPT_BUG + /* - * UnixWare 7+ and OpenServer 5.0.4 are known to have this bug, - * but it shouldn't hurt it catch if for all of them. + * UnixWare 7+ and OpenServer 5.0.4 are known to have this bug, but it + * shouldn't hurt it catch if for all of them. */ if (port->raddr.sa.sa_family == 0) port->raddr.sa.sa_family = AF_UNIX; diff --git a/src/backend/libpq/pqpacket.c b/src/backend/libpq/pqpacket.c index 5e99b148f8e..5f9d3cdb48f 100644 --- a/src/backend/libpq/pqpacket.c +++ b/src/backend/libpq/pqpacket.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.28 2001/01/24 19:42:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.29 2001/03/22 03:59:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,8 +64,8 @@ PacketReceiveFragment(Port *port) #ifndef __BEOS__ got = read(port->sock, pkt->ptr, pkt->nrtodo); #else - got = recv(port->sock, pkt->ptr, pkt->nrtodo, 0); -#endif /* __BEOS__ */ + got = recv(port->sock, pkt->ptr, pkt->nrtodo, 0); +#endif /* __BEOS__ */ if (got > 0) { pkt->nrtodo -= got; diff --git a/src/backend/libpq/pqsignal.c b/src/backend/libpq/pqsignal.c index 668d5f996dd..8cc8f140ace 100644 --- a/src/backend/libpq/pqsignal.c +++ b/src/backend/libpq/pqsignal.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.19 2001/02/10 02:31:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.20 2001/03/22 03:59:30 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -61,10 +61,11 @@ pqinitmask(void) #ifdef HAVE_SIGPROCMASK sigemptyset(&UnBlockSig); sigfillset(&BlockSig); + /* - * Unmark those signals that should never be blocked. - * Some of these signal names don't exist on all platforms. Most do, - * but might as well ifdef them all for consistency... + * Unmark those signals that should never be blocked. Some of these + * signal names don't exist on all platforms. Most do, but might as + * well ifdef them all for consistency... */ #ifdef SIGTRAP sigdelset(&BlockSig, SIGTRAP); |