Move username lookup functions from /port to /common

Per suggestion from Peter E and Alvaro
This commit is contained in:
Bruce Momjian 2014-01-10 18:03:28 -05:00
parent 423e1211a8
commit 111022eac6
11 changed files with 26 additions and 9 deletions

View File

@ -21,6 +21,7 @@
#include <arpa/inet.h>
#include <unistd.h>
#include "common/username.h"
#include "libpq/auth.h"
#include "libpq/crypt.h"
#include "libpq/ip.h"

View File

@ -35,6 +35,7 @@
#endif
#include "bootstrap/bootstrap.h"
#include "common/username.h"
#include "postmaster/postmaster.h"
#include "tcop/tcopprot.h"
#include "utils/help_config.h"

View File

@ -60,6 +60,7 @@
#include "sys/mman.h"
#endif
#include "common/username.h"
#include "mb/pg_wchar.h"
#include "getaddrinfo.h"
#include "getopt_long.h"

View File

@ -23,6 +23,7 @@
#endif
#include "common.h"
#include "common/username.h"
#include "help.h"
#include "input.h"
#include "settings.h"

View File

@ -9,6 +9,7 @@
#ifndef COMMON_H
#define COMMON_H
#include "common/username.h"
#include "libpq-fe.h"
#include "getopt_long.h" /* pgrminclude ignore */
#include "pqexpbuffer.h" /* pgrminclude ignore */

View File

@ -23,7 +23,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
LIBS += $(PTHREAD_LIBS)
OBJS_COMMON = exec.o pgfnames.o psprintf.o relpath.o rmtree.o wait_error.o
OBJS_COMMON = exec.o pgfnames.o psprintf.o relpath.o rmtree.o username.o wait_error.o
OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/port/username.c
* src/common/username.c
*
*-------------------------------------------------------------------------
*/
@ -23,6 +23,7 @@
#include <unistd.h>
#include <sys/types.h>
#include "common/username.h"
/*
* Returns the current user name in a static buffer, or NULL on error and

View File

@ -0,0 +1,15 @@
/*
* username.h
* lookup effective username
*
* Copyright (c) 2003-2014, PostgreSQL Global Development Group
*
* src/include/common/username.h
*/
#ifndef USERNAME_H
#define USERNAME_H
extern const char *get_user_name(char **errstr);
extern const char *get_user_name_or_exit(const char *progname);
#endif /* USERNAME_H */

View File

@ -473,10 +473,6 @@ extern pqsigfunc pqsignal(int signo, pqsigfunc func);
/* port/quotes.c */
extern char *escape_single_quotes_ascii(const char *src);
/* port/username.c */
extern const char *get_user_name(char **errstr);
extern const char *get_user_name_or_exit(const char *progname);
/* port/wait_error.c */
extern char *wait_result_to_str(int exit_status);

View File

@ -33,7 +33,7 @@ LIBS += $(PTHREAD_LIBS)
OBJS = $(LIBOBJS) chklocale.o dirmod.o erand48.o fls.o inet_net_ntop.o \
noblock.o path.o pgcheckdir.o pg_crc.o pgmkdirp.o pgsleep.o \
pgstrcasecmp.o pqsignal.o \
qsort.o qsort_arg.o quotes.o sprompt.o tar.o thread.o username.o
qsort.o qsort_arg.o quotes.o sprompt.o tar.o thread.o
# foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND
OBJS_SRV = $(OBJS:%.o=%_srv.o)

View File

@ -70,11 +70,11 @@ sub mkvcbuild
erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
pgcheckdir.c pg_crc.c pgmkdirp.c pgsleep.c pgstrcasecmp.c pqsignal.c
qsort.c qsort_arg.c quotes.c
sprompt.c tar.c thread.c getopt.c getopt_long.c dirent.c rint.c username.c
sprompt.c tar.c thread.c getopt.c getopt_long.c dirent.c rint.c
win32env.c win32error.c win32setlocale.c);
our @pgcommonallfiles = qw(
exec.c pgfnames.c psprintf.c relpath.c rmtree.c wait_error.c);
exec.c pgfnames.c psprintf.c relpath.c rmtree.c username.c wait_error.c);
our @pgcommonfrontendfiles = (@pgcommonallfiles, qw(fe_memutils.c));