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