diff options
author | Pavel Tikhomirov <ptikhomirov@parallels.com> | 2014-08-27 10:39:00 +0400 |
---|---|---|
committer | Pavel Emelyanov <xemul@parallels.com> | 2014-08-29 16:53:07 +0400 |
commit | 59c968a3bfb46d94703169ede72fd030138352da (patch) | |
tree | e4acfdd42e43f2b3679a534ce76f5b2e8b15e494 | |
parent | dd375cebc920377b40ea55718215ba36ef542a27 (diff) |
zdtm: test that UNIX socket owner/group don't change
In container c/r(OVZ) UNIX socket uid and gid restored from
connected peer credentials instead of inode once.
https://bugzilla.openvz.org/show_bug.cgi?id=2969
changes:
v2 - cleanup headers, close socket, use err instead fail,
print id's on error.
v3 - wrong patch
v4 - move to sockets00, correct patch-message
v5 - minor cleanup
Signed-off-by: Pavel Tikhomirov <ptikhomirov@parallels.com>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
-rwxr-xr-x | test/zdtm.sh | 1 | ||||
-rw-r--r-- | test/zdtm/live/static/sockets00.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/test/zdtm.sh b/test/zdtm.sh index cfbdce27e..eee3342fe 100755 --- a/test/zdtm.sh +++ b/test/zdtm.sh @@ -225,6 +225,7 @@ deleted_dev mntns_open mntns_link_remap mntns_link_ghost +sockets00 " source $(readlink -f `dirname $0`/env.sh) || exit 1 diff --git a/test/zdtm/live/static/sockets00.c b/test/zdtm/live/static/sockets00.c index 6ff93abb0..28beb085f 100644 --- a/test/zdtm/live/static/sockets00.c +++ b/test/zdtm/live/static/sockets00.c @@ -11,6 +11,7 @@ #include <sys/wait.h> #include <sys/un.h> #include <sys/stat.h> +#include <sys/mount.h> #include <limits.h> #include <fcntl.h> @@ -36,6 +37,8 @@ int main(int argc, char *argv[]) char path[PATH_MAX]; char buf[64]; char *cwd; + uid_t uid = 18943; + gid_t gid = 58467; int ret; @@ -74,6 +77,12 @@ int main(int argc, char *argv[]) exit(1); } + ret = chown(path, uid, gid); + if (ret) { + err("chown"); + exit(1); + } + ret = listen(ssk_icon[0], 16); if (ret) { fail("bind\n"); @@ -119,6 +128,12 @@ int main(int argc, char *argv[]) exit(1); } + if (st_b.st_uid != uid || st_b.st_gid != gid) { + fail("Owner user or group for %s corrupted, uid=%d, gid=%d", + path, st_b.st_uid, st_b.st_gid); + exit(1); + } + ret = accept(ssk_icon[0], NULL, NULL); if (ret < 0) { fail("accept\n"); |