diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index a7edcbc0bce2..f72e3bb99cbb 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $NetBSD: ping.c,v 1.92 2010/12/13 17:42:17 pooka Exp $ */ +/* $NetBSD: ping.c,v 1.93 2011/03/11 09:59:56 pooka Exp $ */ /* * Copyright (c) 1989, 1993 @@ -58,7 +58,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ping.c,v 1.92 2010/12/13 17:42:17 pooka Exp $"); +__RCSID("$NetBSD: ping.c,v 1.93 2011/03/11 09:59:56 pooka Exp $"); #endif #include @@ -261,7 +261,7 @@ main(int argc, char *argv[]) if (prog_shutdown(sloop, SHUT_RD) == -1) warn("Cannot shutdown for read"); - if (setuid(getuid()) == -1) + if (prog_setuid(prog_getuid()) == -1) err(1, "setuid"); setprogname(argv[0]); @@ -410,11 +410,11 @@ main(int argc, char *argv[]) if (interval == 0) interval = (pingflags & F_FLOOD) ? FLOOD_INTVL : 1.0; #ifndef sgi - if (pingflags & F_FLOOD && getuid()) + if (pingflags & F_FLOOD && prog_getuid()) errx(1, "Must be superuser to use -f"); - if (interval < 1.0 && getuid()) + if (interval < 1.0 && prog_getuid()) errx(1, "Must be superuser to use < 1 sec ping interval"); - if (preload > 0 && getuid()) + if (preload > 0 && prog_getuid()) errx(1, "Must be superuser to use -l"); #endif sec_to_timeval(interval, &interval_tv); diff --git a/sbin/ping/ping_hostops.c b/sbin/ping/ping_hostops.c index 9d4ccaa426dc..72b1f82fb67d 100644 --- a/sbin/ping/ping_hostops.c +++ b/sbin/ping/ping_hostops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ping_hostops.c,v 1.1 2010/12/13 17:42:17 pooka Exp $ */ +/* $NetBSD: ping_hostops.c,v 1.2 2011/03/11 09:59:56 pooka Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ping_hostops.c,v 1.1 2010/12/13 17:42:17 pooka Exp $"); +__RCSID("$NetBSD: ping_hostops.c,v 1.2 2011/03/11 09:59:56 pooka Exp $"); #endif /* !lint */ #include @@ -48,4 +48,6 @@ const struct prog_ops prog_ops = { .op_recvfrom = recvfrom, .op_sendto = sendto, .op_close = close, + .op_getuid = getuid, + .op_setuid = setuid, }; diff --git a/sbin/ping/ping_rumpops.c b/sbin/ping/ping_rumpops.c index e9816a024841..7e2f2114475e 100644 --- a/sbin/ping/ping_rumpops.c +++ b/sbin/ping/ping_rumpops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ping_rumpops.c,v 1.1 2010/12/13 17:42:17 pooka Exp $ */ +/* $NetBSD: ping_rumpops.c,v 1.2 2011/03/11 09:59:56 pooka Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ping_rumpops.c,v 1.1 2010/12/13 17:42:17 pooka Exp $"); +__RCSID("$NetBSD: ping_rumpops.c,v 1.2 2011/03/11 09:59:56 pooka Exp $"); #endif /* !lint */ #include @@ -53,4 +53,6 @@ const struct prog_ops prog_ops = { .op_sendto = rump_sys_sendto, .op_recvfrom = rump_sys_recvfrom, .op_close = rump_sys_close, + .op_getuid = rump_sys_getuid, + .op_setuid = rump_sys_setuid, }; diff --git a/sbin/ping/prog_ops.h b/sbin/ping/prog_ops.h index c81b4353f918..ccc5a706644b 100644 --- a/sbin/ping/prog_ops.h +++ b/sbin/ping/prog_ops.h @@ -1,4 +1,4 @@ -/* $NetBSD: prog_ops.h,v 1.2 2010/12/13 19:19:10 pooka Exp $ */ +/* $NetBSD: prog_ops.h,v 1.3 2011/03/11 09:59:56 pooka Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -47,6 +47,9 @@ struct prog_ops { const struct sockaddr *, socklen_t); int (*op_close)(int); + + uid_t (*op_getuid)(void); + int (*op_setuid)(uid_t); }; extern const struct prog_ops prog_ops; @@ -58,6 +61,8 @@ extern const struct prog_ops prog_ops; #define prog_recvfrom prog_ops.op_recvfrom #define prog_sendto prog_ops.op_sendto #define prog_close prog_ops.op_close +#define prog_getuid prog_ops.op_getuid +#define prog_setuid prog_ops.op_setuid #else #define prog_init ((int (*)(void))NULL) #define prog_socket socket @@ -67,6 +72,8 @@ extern const struct prog_ops prog_ops; #define prog_recvfrom recvfrom #define prog_sendto sendto #define prog_close close +#define prog_getuid getuid +#define prog_setuid setuid #endif #endif /* _PROG_OPS_H_ */