diff --git a/ls.c b/ls.c
index 0898576..e9829d9 100644
--- a/ls.c
+++ b/ls.c
@@ -502,7 +502,7 @@ build_dir_line(struct mystr* p_str, const struct mystr* p_filename_str,
}
else
{
- int uid = vsf_sysutil_statbuf_get_uid(p_stat);
+ unsigned int uid = vsf_sysutil_statbuf_get_uid(p_stat);
struct vsf_sysutil_user* p_user = 0;
if (tunable_text_userdb_names)
{
@@ -527,7 +527,7 @@ build_dir_line(struct mystr* p_str, const struct mystr* p_filename_str,
}
else
{
- int gid = vsf_sysutil_statbuf_get_gid(p_stat);
+ unsigned int gid = vsf_sysutil_statbuf_get_gid(p_stat);
struct vsf_sysutil_group* p_group = 0;
if (tunable_text_userdb_names)
{
diff --git a/privops.c b/privops.c
index 21d7267..f27c5c4 100644
--- a/privops.c
+++ b/privops.c
@@ -236,8 +236,7 @@ vsf_privop_do_file_chown(struct vsf_session* p_sess, int fd)
/* Drop it like a hot potato unless it's a regular file owned by
* the the anonymous ftp user
*/
- if (p_sess->anon_upload_chown_uid == -1 ||
- !vsf_sysutil_statbuf_is_regfile(s_p_statbuf) ||
+ if (!vsf_sysutil_statbuf_is_regfile(s_p_statbuf) ||
(vsf_sysutil_statbuf_get_uid(s_p_statbuf) != p_sess->anon_ftp_uid &&
vsf_sysutil_statbuf_get_uid(s_p_statbuf) != p_sess->guest_user_uid))
{
diff --git a/session.h b/session.h
index b60e098..4eccf46 100644
--- a/session.h
+++ b/session.h
@@ -56,9 +56,9 @@ struct vsf_session
struct mystr_list* p_visited_dir_list;
/* Details of userids which are interesting to us */
- int anon_ftp_uid;
- int guest_user_uid;
- int anon_upload_chown_uid;
+ unsigned int anon_ftp_uid;
+ unsigned int guest_user_uid;
+ unsigned int anon_upload_chown_uid;
/* Things we need to cache before we chroot() */
struct mystr banned_email_str;
diff --git a/sysutil.c b/sysutil.c
index 24c4a81..954e901 100644
--- a/sysutil.c
+++ b/sysutil.c
@@ -1485,14 +1485,14 @@ vsf_sysutil_statbuf_get_size(const struct vsf_sysutil_statbuf* p_statbuf)
return p_stat->st_size;
}
-int
+unsigned int
vsf_sysutil_statbuf_get_uid(const struct vsf_sysutil_statbuf* p_statbuf)
{
const struct stat* p_stat = (const struct stat*) p_statbuf;
return p_stat->st_uid;
}
-int
+unsigned int
vsf_sysutil_statbuf_get_gid(const struct vsf_sysutil_statbuf* p_statbuf)
{
const struct stat* p_stat = (const struct stat*) p_statbuf;
@@ -1533,7 +1533,7 @@ vsf_sysutil_statbuf_get_sortkey_mtime(
}
void
-vsf_sysutil_fchown(const int fd, const int uid, const int gid)
+vsf_sysutil_fchown(const int fd, const unsigned int uid, const unsigned int gid)
{
if (fchown(fd, uid, gid) != 0)
{
@@ -2351,13 +2351,9 @@ vsf_sysutil_dns_resolve(struct vsf_sysutil_sockaddr** p_sockptr,
}
struct vsf_sysutil_user*
-vsf_sysutil_getpwuid(const int uid)
+vsf_sysutil_getpwuid(const unsigned int uid)
{
- if (uid < 0)
- {
- bug("negative uid in vsf_sysutil_getpwuid");
- }
- return (struct vsf_sysutil_user*) getpwuid((unsigned int) uid);
+ return (struct vsf_sysutil_user*) getpwuid(uid);
}
struct vsf_sysutil_user*
@@ -2380,14 +2376,14 @@ vsf_sysutil_user_get_homedir(const struct vsf_sysutil_user* p_user)
return p_passwd->pw_dir;
}
-int
+unsigned int
vsf_sysutil_user_getuid(const struct vsf_sysutil_user* p_user)
{
const struct passwd* p_passwd = (const struct passwd*) p_user;
return p_passwd->pw_uid;
}
-int
+unsigned int
vsf_sysutil_user_getgid(const struct vsf_sysutil_user* p_user)
{
const struct passwd* p_passwd = (const struct passwd*) p_user;
@@ -2395,13 +2391,9 @@ vsf_sysutil_user_getgid(const struct vsf_sysutil_user* p_user)
}
struct vsf_sysutil_group*
-vsf_sysutil_getgrgid(const int gid)
+vsf_sysutil_getgrgid(const unsigned int gid)
{
- if (gid < 0)
- {
- die("negative gid in vsf_sysutil_getgrgid");
- }
- return (struct vsf_sysutil_group*) getgrgid((unsigned int) gid);
+ return (struct vsf_sysutil_group*) getgrgid(gid);
}
const char*
@@ -2476,25 +2468,17 @@ vsf_sysutil_setgid_numeric(int gid)
}
}
-int
+unsigned int
vsf_sysutil_geteuid(void)
{
- int retval = geteuid();
- if (retval < 0)
- {
- die("geteuid");
- }
+ unsigned int retval = geteuid();
return retval;
}
-int
+unsigned int
vsf_sysutil_getegid(void)
{
- int retval = getegid();
- if (retval < 0)
- {
- die("getegid");
- }
+ unsigned int retval = getegid();
return retval;
}
@@ -2885,7 +2869,7 @@ vsf_sysutil_ftruncate(int fd)
}
}
-int
+unsigned int
vsf_sysutil_getuid(void)
{
return getuid();
diff --git a/sysutil.h b/sysutil.h
index 399c921..b745d4a 100644
--- a/sysutil.h
+++ b/sysutil.h
@@ -130,15 +130,15 @@ const char* vsf_sysutil_statbuf_get_numeric_date(
const struct vsf_sysutil_statbuf* p_stat, int use_localtime);
unsigned int vsf_sysutil_statbuf_get_links(
const struct vsf_sysutil_statbuf* p_stat);
-int vsf_sysutil_statbuf_get_uid(const struct vsf_sysutil_statbuf* p_stat);
-int vsf_sysutil_statbuf_get_gid(const struct vsf_sysutil_statbuf* p_stat);
+unsigned int vsf_sysutil_statbuf_get_uid(const struct vsf_sysutil_statbuf* p_stat);
+unsigned int vsf_sysutil_statbuf_get_gid(const struct vsf_sysutil_statbuf* p_stat);
int vsf_sysutil_statbuf_is_readable_other(
const struct vsf_sysutil_statbuf* p_stat);
const char* vsf_sysutil_statbuf_get_sortkey_mtime(
const struct vsf_sysutil_statbuf* p_stat);
int vsf_sysutil_chmod(const char* p_filename, unsigned int mode);
-void vsf_sysutil_fchown(const int fd, const int uid, const int gid);
+void vsf_sysutil_fchown(const int fd, const unsigned int uid, const unsigned int gid);
void vsf_sysutil_fchmod(const int fd, unsigned int mode);
int vsf_sysutil_readlink(const char* p_filename, char* p_dest,
unsigned int bufsiz);
@@ -292,15 +292,15 @@ int vsf_sysutil_inet_aton(
struct vsf_sysutil_user;
struct vsf_sysutil_group;
-struct vsf_sysutil_user* vsf_sysutil_getpwuid(const int uid);
+struct vsf_sysutil_user* vsf_sysutil_getpwuid(const unsigned int uid);
struct vsf_sysutil_user* vsf_sysutil_getpwnam(const char* p_user);
const char* vsf_sysutil_user_getname(const struct vsf_sysutil_user* p_user);
const char* vsf_sysutil_user_get_homedir(
const struct vsf_sysutil_user* p_user);
-int vsf_sysutil_user_getuid(const struct vsf_sysutil_user* p_user);
-int vsf_sysutil_user_getgid(const struct vsf_sysutil_user* p_user);
+unsigned int vsf_sysutil_user_getuid(const struct vsf_sysutil_user* p_user);
+unsigned int vsf_sysutil_user_getgid(const struct vsf_sysutil_user* p_user);
-struct vsf_sysutil_group* vsf_sysutil_getgrgid(const int gid);
+struct vsf_sysutil_group* vsf_sysutil_getgrgid(const unsigned int gid);
const char* vsf_sysutil_group_getname(const struct vsf_sysutil_group* p_group);
/* More random things */
@@ -318,7 +318,7 @@ void vsf_sysutil_qsort(void* p_base, unsigned int num_elem,
char* vsf_sysutil_getenv(const char* p_var);
typedef void (*exitfunc_t)(void);
void vsf_sysutil_set_exit_func(exitfunc_t exitfunc);
-int vsf_sysutil_getuid(void);
+unsigned int vsf_sysutil_getuid(void);
/* Syslogging (bah) */
void vsf_sysutil_openlog(int force);
@@ -331,8 +331,8 @@ void vsf_sysutil_setuid(const struct vsf_sysutil_user* p_user);
void vsf_sysutil_setgid(const struct vsf_sysutil_user* p_user);
void vsf_sysutil_setuid_numeric(int uid);
void vsf_sysutil_setgid_numeric(int gid);
-int vsf_sysutil_geteuid(void);
-int vsf_sysutil_getegid(void);
+unsigned int vsf_sysutil_geteuid(void);
+unsigned int vsf_sysutil_getegid(void);
void vsf_sysutil_seteuid(const struct vsf_sysutil_user* p_user);
void vsf_sysutil_setegid(const struct vsf_sysutil_user* p_user);
void vsf_sysutil_seteuid_numeric(int uid);