summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libexec/argc.c6
-rw-r--r--src/libexec/peereid.c12
-rw-r--r--src/libexec/peerip.c3
-rw-r--r--src/libexec/sockip.c3
4 files changed, 22 insertions, 2 deletions
diff --git a/src/libexec/argc.c b/src/libexec/argc.c
new file mode 100644
index 0000000..9c35294
--- /dev/null
+++ b/src/libexec/argc.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc,char *argv[]) {
+ printf("argc:%d\n",argc);
+ return argc;
+}
diff --git a/src/libexec/peereid.c b/src/libexec/peereid.c
new file mode 100644
index 0000000..e2e5c5f
--- /dev/null
+++ b/src/libexec/peereid.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int main(int argc,char *argv[]) {
+ uid_t euid;
+ gid_t egid;
+ if(getpeereid(argc>1?atoi(argv[1]):0,&euid,&egid) == -1) return 1;
+ printf("%d\n%d\n",euid,egid);
+ return 0;
+}
diff --git a/src/libexec/peerip.c b/src/libexec/peerip.c
index 43d64d0..88b8fd4 100644
--- a/src/libexec/peerip.c
+++ b/src/libexec/peerip.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
@@ -7,7 +8,7 @@ int main(int argc,char *argv[]) {
struct sockaddr_in6 sa6;
unsigned int sl=sizeof(sa6);
char h[NI_MAXHOST], s[NI_MAXSERV];
- if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1) return 1;
+ if(getpeername(argc>1?atoi(argv[1]):0,(struct sockaddr *)&sa6,&sl) == -1) return 1;
if(getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) return 2;
puts(h);
puts(s);
diff --git a/src/libexec/sockip.c b/src/libexec/sockip.c
index 542a88d..f1f0480 100644
--- a/src/libexec/sockip.c
+++ b/src/libexec/sockip.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
@@ -7,7 +8,7 @@ int main(int argc,char *argv[]) {
struct sockaddr_in6 sa6;
unsigned int sl=sizeof(sa6);
char h[NI_MAXHOST], s[NI_MAXSERV];
- if(getsockname(0,(struct sockaddr *)&sa6,&sl) == -1) return 1;
+ if(getsockname(argc>1?atoi(argv[1]):0,(struct sockaddr *)&sa6,&sl) == -1) return 1;
if(getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) return 2;
puts(h);
puts(s);