Skip to content

Commit

Permalink
Remove -a (disable tcp wrappers) option.
Browse files Browse the repository at this point in the history
Fix some minor nits that prevented test suite from working on ubuntu 10.10.
  • Loading branch information
garlick committed Mar 12, 2011
1 parent 26bca3c commit 48486b1
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 65 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
@@ -1,3 +1,13 @@
2011-03-12 Jim Garlick <garlick@llnl.gov>

* tests/user/tstat.c : Don't print inode difference.

* tests/user/tread.c : Provide missing open () mode argument.

* libdiod/diod_conf.[ch], libdiod/diod_sock.[ch], diod/diod.c,
diodctl/diodctl.c : Drop support for -a option (disable tcp wrappers).
If wrappers are compiled in, disable checks by configuring wrappers.

2011-03-11 Jim Garlick <garlick@llnl.gov>

* libnpclient/read.c : Fix bug in np_gets ().
Expand Down
19 changes: 5 additions & 14 deletions diod/diod.c
Expand Up @@ -57,7 +57,7 @@
#define NR_OPEN 1048576 /* works on RHEL 5 x86_64 arch */
#endif

#define OPTIONS "d:l:w:e:E:aF:u:A:L:s:n"
#define OPTIONS "d:l:w:e:E:F:u:A:L:s:n"

#if HAVE_GETOPT_LONG
#define GETOPT(ac,av,opt,lopt) getopt_long (ac,av,opt,lopt,NULL)
Expand All @@ -67,7 +67,6 @@ static const struct option longopts[] = {
{"nwthreads", required_argument, 0, 'w'},
{"export", required_argument, 0, 'e'},
{"export-file", required_argument, 0, 'E'},
{"no-wrap", no_argument, 0, 'a'},
{"no-auth", no_argument, 0, 'n'},
{"listen-fds", required_argument, 0, 'F'},
{"runas-uid", required_argument, 0, 'u'},
Expand Down Expand Up @@ -95,8 +94,7 @@ usage()
" -A,--atomic-max INT set the maximum atomic I/O size, in megabytes\n"
" -L,--log-to DEST log to DEST, can be syslog, stderr, or file\n"
" -s,--stats FILE log detailed I/O stats to FILE\n"
" -a,--no-wrap disable TCP wrappers checks (allow any host)\n"
" -n,--no-auth disable authentication check (allow any user)\n"
" -n,--no-auth disable authentication check\n"
);
exit (1);
}
Expand Down Expand Up @@ -157,10 +155,7 @@ main(int argc, char **argv)
}
diod_conf_read_exports (optarg);
break;
case 'a': /* --no-wrap */
diod_conf_set_tcpwrappers (0);
break;
case 'n': /* --no--auth */
case 'n': /* --no-auth */
diod_conf_set_auth_required (0);
break;
case 'F': /* --listen-fds N */
Expand Down Expand Up @@ -198,10 +193,6 @@ main(int argc, char **argv)
usage();

diod_conf_validate_exports ();
#if ! HAVE_TCP_WRAPPERS
if (diod_conf_get_tcpwrappers ())
msg_exit ("no TCP wrapper support, yet config enables it");
#endif
if (diod_conf_get_runasuid (&uid)) {
if (geteuid () != 0 && geteuid () != uid)
msg_exit ("must be root to run diod as another user");
Expand All @@ -222,11 +213,11 @@ main(int argc, char **argv)
if (Fopt) {
if (!diod_sock_listen_nfds (&fds, &nfds, Fopt, 3))
msg_exit ("failed to set up listen ports");
diod_sock_accept_batch (srv, fds, nfds, diod_conf_get_tcpwrappers ());
diod_sock_accept_batch (srv, fds, nfds);
} else if ((hplist = diod_conf_get_diodlisten ())) {
if (!diod_sock_listen_hostport_list (hplist, &fds, &nfds, NULL, 0))
msg_exit ("failed to set up listen ports");
diod_sock_accept_loop (srv, fds, nfds, diod_conf_get_tcpwrappers ());
diod_sock_accept_loop (srv, fds, nfds);
/*NOTREACHED*/
} else {
diod_sock_startfd (srv, 0, "stdin", "0.0.0.0", "0", 1);
Expand Down
13 changes: 2 additions & 11 deletions diodctl/diodctl.c
Expand Up @@ -73,7 +73,7 @@ static void _setrlimit (void);
#define NR_OPEN 1048576 /* works on RHEL 5 x86_64 arch */
#endif

#define OPTIONS "fd:l:w:c:e:anD:L:"
#define OPTIONS "fd:l:w:c:e:nD:L:"
#if HAVE_GETOPT_LONG
#define GETOPT(ac,av,opt,lopt) getopt_long (ac,av,opt,lopt,NULL)
static const struct option longopts[] = {
Expand All @@ -83,7 +83,6 @@ static const struct option longopts[] = {
{"nwthreads", required_argument, 0, 'w'},
{"config-file", required_argument, 0, 'c'},
{"export", required_argument, 0, 'e'},
{"allowany", no_argument, 0, 'a'},
{"no-auth", no_argument, 0, 'n'},
{"diod-path", required_argument, 0, 'D'},
{"log-dest", required_argument, 0, 'L'},
Expand All @@ -104,7 +103,6 @@ usage()
" -w,--nwthreads INT set number of I/O worker threads to spawn\n"
" -c,--config-file FILE set config file path\n"
" -e,--export PATH export PATH (just one allowed)\n"
" -a,--allowany disable TCP wrappers checks\n"
" -n,--no-auth disable authentication check\n"
" -D,--diod-path PATH set path to diod executable\n"
" -L,--log-dest DEST log to DEST, can be syslog, stderr, or file\n"
Expand Down Expand Up @@ -177,9 +175,6 @@ main(int argc, char **argv)
}
diod_conf_add_export (optarg);
break;
case 'a': /* --allowany */
diod_conf_set_tcpwrappers (0);
break;
case 'n': /* --no-auth */
diod_conf_set_auth_required (0);
break;
Expand All @@ -199,10 +194,6 @@ main(int argc, char **argv)

/* sane config? */
diod_conf_validate_exports ();
#if ! HAVE_TCP_WRAPPERS
if (diod_conf_get_tcpwrappers ())
msg_exit ("no TCP wrapper support but config enables it");
#endif

if (geteuid () != 0)
msg_exit ("must run as root");
Expand All @@ -221,7 +212,7 @@ main(int argc, char **argv)

diodctl_serv_init ();
diodctl_register_ops (srv);
diod_sock_accept_loop (srv, fds, nfds, diod_conf_get_tcpwrappers ());
diod_sock_accept_loop (srv, fds, nfds);
/*NOTREACHED*/

exit (0);
Expand Down
2 changes: 0 additions & 2 deletions diodctl/serv.c
Expand Up @@ -296,8 +296,6 @@ _build_server_args (Server *s)
goto done;
if (_append_arg (s, "-A%d", diod_conf_get_atomic_max ()) < 0)
goto done;
if (!diod_conf_get_tcpwrappers () && _append_arg (s, "-a") < 0)
goto done;
if (!diod_conf_get_auth_required () && _append_arg (s, "-n") < 0)
goto done;
if (_append_arg (s, "-E%s", exports_file) < 0)
Expand Down
14 changes: 0 additions & 14 deletions libdiod/diod_conf.c
Expand Up @@ -57,7 +57,6 @@ typedef struct {
int nwthreads;
int foreground;
int auth_required;
int tcpwrappers;
uid_t runasuid;
int runasuid_valid;
char *diodpath;
Expand All @@ -73,7 +72,6 @@ static Conf config = {
.nwthreads = 16,
.foreground = 0,
.auth_required = 1,
.tcpwrappers = 1,
.runasuid_valid = 0,
.diodpath = NULL, /* diod_conf_init initializes */
.diodlisten = NULL, /* diod_conf_init initializes */
Expand Down Expand Up @@ -139,18 +137,6 @@ diod_conf_set_auth_required (int i)
config.auth_required = i;
}

int
diod_conf_get_tcpwrappers (void)
{
return config.tcpwrappers;
}

void
diod_conf_set_tcpwrappers (int i)
{
config.tcpwrappers = i;
}

int
diod_conf_get_runasuid (uid_t *uidp)
{
Expand Down
3 changes: 0 additions & 3 deletions libdiod/diod_conf.h
Expand Up @@ -40,9 +40,6 @@ void diod_conf_set_nwthreads (int i);
int diod_conf_get_foreground (void);
void diod_conf_set_foreground (int i);

int diod_conf_get_tcpwrappers (void);
void diod_conf_set_tcpwrappers (int i);

int diod_conf_get_auth_required (void);
void diod_conf_set_auth_required (int i);

Expand Down
24 changes: 10 additions & 14 deletions libdiod/diod_sock.c
Expand Up @@ -234,7 +234,7 @@ diod_sock_startfd (Npsrv *srv, int fd, char *host, char *ip, char *svc,
* This is a helper for diod_sock_accept_loop ().
*/
static void
_accept_one (Npsrv *srv, int fd, int wrap)
_accept_one (Npsrv *srv, int fd)
{
struct sockaddr_storage addr;
socklen_t addr_size = sizeof(addr);
Expand Down Expand Up @@ -262,13 +262,11 @@ _accept_one (Npsrv *srv, int fd, int wrap)
return;
}
#if HAVE_TCP_WRAPPERS
if (wrap) {
res = hosts_ctl (DAEMON_NAME, host, ip, STRING_UNKNOWN);
if (!res) {
msg ("connect denied by wrappers: %s:%s", host, svc);
close (fd);
return;
}
res = hosts_ctl (DAEMON_NAME, host, ip, STRING_UNKNOWN);
if (!res) {
msg ("connect denied by wrappers: %s:%s", host, svc);
close (fd);
return;
}
#endif
diod_sock_startfd (srv, fd, host, ip, svc, 0);
Expand All @@ -278,7 +276,7 @@ _accept_one (Npsrv *srv, int fd, int wrap)
* This comprises the main service loop in diod -L and diodctl daemons.
*/
void
diod_sock_accept_loop (Npsrv *srv, struct pollfd *fds, int nfds, int wrap)
diod_sock_accept_loop (Npsrv *srv, struct pollfd *fds, int nfds)
{
int i;

Expand All @@ -294,7 +292,7 @@ diod_sock_accept_loop (Npsrv *srv, struct pollfd *fds, int nfds, int wrap)
}
for (i = 0; i < nfds; i++) {
if ((fds[i].revents & POLLIN)) {
_accept_one (srv, fds[i].fd, wrap);
_accept_one (srv, fds[i].fd);
}
}
}
Expand All @@ -307,30 +305,28 @@ typedef struct {
Npsrv *srv;
struct pollfd *fds;
int nfds;
int wrap;
} ala_t;

static void *
_accept_thread (void *ap)
{
ala_t *a = ap;
diod_sock_accept_loop (a->srv, a->fds, a->nfds, a->wrap);
diod_sock_accept_loop (a->srv, a->fds, a->nfds);
return NULL;
}

/* Loop accepting and handling new 9P connections.
* Quit once connection count goes above zero then drops to zero again.
*/
void
diod_sock_accept_batch (Npsrv *srv, struct pollfd *fds, int nfds, int wrap)
diod_sock_accept_batch (Npsrv *srv, struct pollfd *fds, int nfds)
{
ala_t a;
pthread_t thd;

a.srv = srv;
a.fds = fds;
a.nfds = nfds;
a.wrap = wrap;
pthread_create (&thd, NULL, _accept_thread, &a);
np_srv_wait_zeroconns (srv);
}
Expand Down
6 changes: 2 additions & 4 deletions libdiod/diod_sock.h
Expand Up @@ -13,11 +13,9 @@ void diod_sock_startfd (Npsrv *srv, int fd, char *host, char *ip, char *svc,
int diod_sock_listen_hostport_list (List l, struct pollfd **fdsp, int *nfdsp,
char *nport, int flags);

void diod_sock_accept_loop (Npsrv *srv, struct pollfd *fds, int nfds,
int wrap);
void diod_sock_accept_loop (Npsrv *srv, struct pollfd *fds, int nfds);

void diod_sock_accept_batch (Npsrv *srv, struct pollfd *fds, int nfds,
int wrap);
void diod_sock_accept_batch (Npsrv *srv, struct pollfd *fds, int nfds);

int diod_sock_connect (char *host, char *port, int maxtries, int retry_wait_ms);

Expand Down
2 changes: 1 addition & 1 deletion tests/user/t08.exp
@@ -1,6 +1,6 @@
creating file
comparing status
tstat: dev differs
tstat: ino differs by 2
tstat: ino differs
conjoin: t08 exited with rc=0
conjoin: diod exited with rc=0
2 changes: 1 addition & 1 deletion tests/user/tread.c
Expand Up @@ -64,7 +64,7 @@ main (int argc, char *argv[])
infile = argv[2];
outfile = argv[3];

if ((fd = open (outfile, O_WRONLY | O_CREAT)) < 0)
if ((fd = open (outfile, O_WRONLY | O_CREAT, 0644)) < 0)
err_exit ("open");

if (!(fs = npc_mount (0, 65536+24, aname, diod_auth_client_handshake)))
Expand Down
2 changes: 1 addition & 1 deletion tests/user/tstat.c
Expand Up @@ -58,7 +58,7 @@ main (int argc, char *argv[])
if (sb1.st_dev != sb2.st_dev)
msg ("dev differs");
if (sb1.st_ino != sb2.st_ino)
msg ("ino differs by %"PRIu64, sb2.st_ino - sb1.st_ino);
msg ("ino differs");
if (sb1.st_mode != sb2.st_mode)
msg ("mode differs");
if (sb1.st_nlink != sb2.st_nlink)
Expand Down

0 comments on commit 48486b1

Please sign in to comment.