From e6a5210d08acdebb24ac1d37007a08cf66e93491 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Sun, 12 Jan 2014 06:39:58 -0500 Subject: [PATCH] qfile-dom0-unpacker: some error checking --- dom0-updates/qfile-dom0-unpacker.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/dom0-updates/qfile-dom0-unpacker.c b/dom0-updates/qfile-dom0-unpacker.c index 13ea3de..d1bbe04 100644 --- a/dom0-updates/qfile-dom0-unpacker.c +++ b/dom0-updates/qfile-dom0-unpacker.c @@ -33,9 +33,15 @@ int prepare_creds_return_uid(const char *username) } setenv("HOME", pwd->pw_dir, 1); setenv("USER", pwd->pw_name, 1); - setgid(pwd->pw_gid); + if (setgid(pwd->pw_gid) < 0) { + perror("setgid"); + exit(1); + } initgroups(pwd->pw_name, pwd->pw_gid); - setfsuid(pwd->pw_uid); + if (setfsuid(pwd->pw_uid) < 0) { + perror("setfsuid"); + exit(1); + } return pwd->pw_uid; } @@ -69,7 +75,10 @@ int main(int argc, char ** argv) fprintf(stderr, "Error chroot to %s", incoming_dir); exit(1); } - setuid(uid); + if (setuid(uid) < 0) { + perror("setuid"); + exit(1); + } set_size_limit(bytes_limit, files_limit); if (argc > 3 && strcmp(argv[3],"-v")==0) set_verbose(1);