Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ping Make get/setuid prog ops (so that i can do rump.pi...
details: https://anonhg.NetBSD.org/src/rev/b7da3e3f5cc0
branches: trunk
changeset: 763148:b7da3e3f5cc0
user: pooka <pooka%NetBSD.org@localhost>
date: Fri Mar 11 09:59:56 2011 +0000
description:
Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).
diffstat:
sbin/ping/ping.c | 12 ++++++------
sbin/ping/ping_hostops.c | 6 ++++--
sbin/ping/ping_rumpops.c | 6 ++++--
sbin/ping/prog_ops.h | 9 ++++++++-
4 files changed, 22 insertions(+), 11 deletions(-)
diffs (129 lines):
diff -r 4e20f6c20fef -r b7da3e3f5cc0 sbin/ping/ping.c
--- a/sbin/ping/ping.c Fri Mar 11 09:25:59 2011 +0000
+++ b/sbin/ping/ping.c Fri Mar 11 09:59:56 2011 +0000
@@ -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 <sys/cdefs.h>
#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 <stdio.h>
@@ -261,7 +261,7 @@
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 @@
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 -r 4e20f6c20fef -r b7da3e3f5cc0 sbin/ping/ping_hostops.c
--- a/sbin/ping/ping_hostops.c Fri Mar 11 09:25:59 2011 +0000
+++ b/sbin/ping/ping_hostops.c Fri Mar 11 09:59:56 2011 +0000
@@ -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 <sys/cdefs.h>
#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 <sys/types.h>
@@ -48,4 +48,6 @@
.op_recvfrom = recvfrom,
.op_sendto = sendto,
.op_close = close,
+ .op_getuid = getuid,
+ .op_setuid = setuid,
};
diff -r 4e20f6c20fef -r b7da3e3f5cc0 sbin/ping/ping_rumpops.c
--- a/sbin/ping/ping_rumpops.c Fri Mar 11 09:25:59 2011 +0000
+++ b/sbin/ping/ping_rumpops.c Fri Mar 11 09:59:56 2011 +0000
@@ -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 <sys/cdefs.h>
#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 <sys/types.h>
@@ -53,4 +53,6 @@
.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 -r 4e20f6c20fef -r b7da3e3f5cc0 sbin/ping/prog_ops.h
--- a/sbin/ping/prog_ops.h Fri Mar 11 09:25:59 2011 +0000
+++ b/sbin/ping/prog_ops.h Fri Mar 11 09:59:56 2011 +0000
@@ -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 @@
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 @@
#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 @@
#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_ */
Home |
Main Index |
Thread Index |
Old Index