diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2015-07-08 07:08:31 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2015-07-08 07:08:31 +0200 |
commit | fb183854ab9b5774094a753ad3f46b653a9055da (patch) | |
tree | f3854bb3a4703a39aedff451b874e7cf9e53c699 /src/basic | |
parent | 86f210e9c914ba12477d4b2e7fa6f5cfa196a324 (diff) | |
download | systemd-fb183854ab9b5774094a753ad3f46b653a9055da.tar.gz |
Imported Upstream version 222
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/.gitignore | 16 | ||||
l--------- | src/basic/Makefile | 1 | ||||
-rw-r--r-- | src/basic/fileio.c | 11 | ||||
-rw-r--r-- | src/basic/fileio.h | 2 | ||||
l--------- | src/basic/linux/Makefile | 1 | ||||
-rw-r--r-- | src/basic/path-util.c | 2 | ||||
-rw-r--r-- | src/basic/process-util.c | 3 | ||||
-rw-r--r-- | src/basic/socket-label.c | 9 | ||||
-rw-r--r-- | src/basic/socket-util.h | 1 | ||||
-rw-r--r-- | src/basic/util.c | 9 |
10 files changed, 48 insertions, 7 deletions
diff --git a/src/basic/.gitignore b/src/basic/.gitignore new file mode 100644 index 0000000000..e22411e484 --- /dev/null +++ b/src/basic/.gitignore @@ -0,0 +1,16 @@ +/cap-from-name.gperf +/cap-from-name.h +/cap-list.txt +/cap-to-name.h +/errno-from-name.gperf +/errno-from-name.h +/errno-list.txt +/errno-to-name.h +/af-from-name.gperf +/af-from-name.h +/af-list.txt +/af-to-name.h +/arphrd-from-name.gperf +/arphrd-from-name.h +/arphrd-list.txt +/arphrd-to-name.h diff --git a/src/basic/Makefile b/src/basic/Makefile new file mode 120000 index 0000000000..d0b0e8e008 --- /dev/null +++ b/src/basic/Makefile @@ -0,0 +1 @@ +../Makefile
\ No newline at end of file diff --git a/src/basic/fileio.c b/src/basic/fileio.c index ff6b1a7ed7..00fb6f8b5c 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -134,6 +134,17 @@ int read_one_line_file(const char *fn, char **line) { return 0; } +int verify_one_line_file(const char *fn, const char *line) { + _cleanup_free_ char *value = NULL; + int r; + + r = read_one_line_file(fn, &value); + if (r < 0) + return r; + + return streq(value, line); +} + int read_full_stream(FILE *f, char **contents, size_t *size) { size_t n, l; _cleanup_free_ char *buf = NULL; diff --git a/src/basic/fileio.h b/src/basic/fileio.h index 5ae51c1e28..91d4a0d2d5 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -34,6 +34,8 @@ int read_one_line_file(const char *fn, char **line); int read_full_file(const char *fn, char **contents, size_t *size); int read_full_stream(FILE *f, char **contents, size_t *size); +int verify_one_line_file(const char *fn, const char *line); + int parse_env_file(const char *fname, const char *separator, ...) _sentinel_; int load_env_file(FILE *f, const char *fname, const char *separator, char ***l); int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l); diff --git a/src/basic/linux/Makefile b/src/basic/linux/Makefile new file mode 120000 index 0000000000..d0b0e8e008 --- /dev/null +++ b/src/basic/linux/Makefile @@ -0,0 +1 @@ +../Makefile
\ No newline at end of file diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 537705446a..8f49d65266 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -528,7 +528,7 @@ int fd_is_mount_point(int fd, const char *filename, int flags) { * * If that didn't work we will try to read the mount id from * /proc/self/fdinfo/<fd>. This is almost as good as - * name_to_handle_at(), however, does not return the the + * name_to_handle_at(), however, does not return the * opaque file handle. The opaque file handle is pretty useful * to detect the root directory, which we should always * consider a mount point. Hence we use this only as diff --git a/src/basic/process-util.c b/src/basic/process-util.c index cfc876567d..2c05f2fee4 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -329,6 +329,9 @@ int get_process_environ(pid_t pid, char **env) { sz += cescape_char(c, outcome + sz); } + if (sz == 0) + return -ENOENT; + outcome[sz] = '\0'; *env = outcome; outcome = NULL; diff --git a/src/basic/socket-label.c b/src/basic/socket-label.c index cbe3ff216e..144e6fd86e 100644 --- a/src/basic/socket-label.c +++ b/src/basic/socket-label.c @@ -38,6 +38,7 @@ int socket_address_listen( int backlog, SocketAddressBindIPv6Only only, const char *bind_to_device, + bool reuse_port, bool free_bind, bool transparent, mode_t directory_mode, @@ -83,6 +84,12 @@ int socket_address_listen( if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, bind_to_device, strlen(bind_to_device)+1) < 0) return -errno; + if (reuse_port) { + one = 1; + if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0) + log_warning_errno(errno, "SO_REUSEPORT failed: %m"); + } + if (free_bind) { one = 1; if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &one, sizeof(one)) < 0) @@ -146,7 +153,7 @@ int make_socket_fd(int log_level, const char* address, int flags) { } fd = socket_address_listen(&a, flags, SOMAXCONN, SOCKET_ADDRESS_DEFAULT, - NULL, false, false, 0755, 0644, NULL); + NULL, false, false, false, 0755, 0644, NULL); if (fd < 0 || log_get_max_level() >= log_level) { _cleanup_free_ char *p = NULL; diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h index 538cf59174..6b0ce7836f 100644 --- a/src/basic/socket-util.h +++ b/src/basic/socket-util.h @@ -80,6 +80,7 @@ int socket_address_listen( int backlog, SocketAddressBindIPv6Only only, const char *bind_to_device, + bool reuse_port, bool free_bind, bool transparent, mode_t directory_mode, diff --git a/src/basic/util.c b/src/basic/util.c index 727be56f58..aa912bde28 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -3627,7 +3627,7 @@ bool string_is_safe(const char *p) { if (*t > 0 && *t < ' ') return false; - if (strchr("\\\"\'\0x7f", *t)) + if (strchr("\\\"\'\x7f", *t)) return false; } @@ -5925,10 +5925,9 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char if (ret >= 0) return 0; - /* Even though renameat2() exists since Linux 3.15, btrfs added - * support for it later. If it is not implemented, fallback to another - * method. */ - if (errno != EINVAL) + /* renameat2() exists since Linux 3.15, btrfs added support for it later. + * If it is not implemented, fallback to another method. */ + if (!IN_SET(errno, EINVAL, ENOSYS)) return -errno; /* The link()/unlink() fallback does not work on directories. But |