#include <stropts.h>
#endif
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
#if HAVE_SYS_CONF_H
#include <sys/conf.h>
#endif
c->auth = 0;
} else {
c->uid = p->pw_uid;
+ c->gid = p->pw_gid;
strncpy(c->curr_dir, p->pw_dir, 254);
c->curr_dir[254] = 0;
}
) {
c->auth = 0;
} else {
- c->auth = 3;
+ c->auth = 4;
}
}
#endif /* !WANT_NONROOT */
chdir(c->curr_dir);
dump_file(c, 230, "welcome.msg");
#endif
+ /* Have a different message for anonymous users? */
numeric(c, 230, "User logged in.");
}
return 1;
#if !WANT_NONROOT
/* need root privilegies for a short while */
seteuid(getuid());
+ setegid(getgid());
#endif
bind(sock, (struct sockaddr *)&sin, sizeof(sin));
#if !WANT_NONROOT
seteuid(c->uid);
+ setegid(c->gid);
#endif
f->sin.sin_family = AF_INET;
"Waiting for e-mail address",
"Waiting for password",
"Logged in",
- "Waiting for password", /* actually non-existant user */
+ "Logged in", /* non-anonymous */
};
char ftran_state[6][42] = {
* down without clearing any sockets etc. In other words:
* Don't use it on a production site.
*/
-void cmd_exit(struct conn * const c)
+int cmd_exit(struct conn * const c)
{
while (first_conn->next_conn)
destroy_conn(first_conn->next_conn);
#if !WANT_NONROOT
if (h->do_setuid) {
seteuid(c->uid);
+ setegid(c->gid);
} else {
- seteuid(0);
+ seteuid(getuid());
+ setegid(getgid());
}
#endif
if (h->callback(c)) {
c->recv_buf[cmlen] = schar;
#if !WANT_NONROOT
- if (h->do_setuid) seteuid(getuid());
+ if (h->do_setuid) {
+ seteuid(getuid());
+ setegid(getgid());
+ }
#endif
remove_bytes(c, cmlen);
}