1 /*
2  * PgBouncer - Lightweight connection pooler for PostgreSQL.
3  *
4  * Copyright (c) 2007-2009  Marko Kreen, Skype Technologies OÜ
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  * Required system headers
21  */
22 
23 #include <usual/base.h>
24 #include <usual/ctype.h>
25 
26 #ifdef WIN32
27 #include "win32support.h"
28 #endif
29 
30 #include <sys/stat.h>
31 
32 #include <stdarg.h>
33 #include <limits.h>
34 
35 #include <usual/tls/tls.h>
36 
37 #ifdef HAVE_LIBGEN_H
38 #include <libgen.h>
39 #endif
40 #ifdef HAVE_SYS_UIO_H
41 #include <sys/uio.h>
42 #endif
43 
44 /*
45  * libc compat functions.
46  */
47 
48 #ifndef HAVE_LSTAT
lstat(const char * path,struct stat * st)49 static inline int lstat(const char *path, struct stat *st) { return stat(path, st); }
50 #endif
51 
52 bool check_unix_peer_name(int fd, const char *username);
53 
54 void change_user(const char *user);
55 
56 void change_file_mode(const char *fn, mode_t mode, const char *user, const char *group);
57