Add support for bindat(2) and connectat(2).
Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
378a73d1bd
commit
7099ae5f3d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=247669
@ -6,7 +6,7 @@ ${PROG}: ${PROG}.c
|
||||
@OSTYPE=`uname`; \
|
||||
CFLAGS=-D__OS_$${OSTYPE}__; \
|
||||
if [ $$OSTYPE = "FreeBSD" ]; then \
|
||||
CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_FCHFLAGS -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL"; \
|
||||
CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_FCHFLAGS -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL -DHAS_BINDAT -DHAS_CONNECTAT"; \
|
||||
elif [ $$OSTYPE = "SunOS" ]; then \
|
||||
CFLAGS="$$CFLAGS -DHAS_TRUNCATE64 -DHAS_STAT64"; \
|
||||
CFLAGS="$$CFLAGS -lsocket"; \
|
||||
|
@ -82,7 +82,13 @@ enum action {
|
||||
ACTION_MKNOD,
|
||||
ACTION_MKNODAT,
|
||||
ACTION_BIND,
|
||||
#ifdef HAS_BINDAT
|
||||
ACTION_BINDAT,
|
||||
#endif
|
||||
ACTION_CONNECT,
|
||||
#ifdef HAS_CONNECTAT
|
||||
ACTION_CONNECTAT,
|
||||
#endif
|
||||
ACTION_CHMOD,
|
||||
ACTION_FCHMOD,
|
||||
#ifdef HAS_LCHMOD
|
||||
@ -154,7 +160,13 @@ static struct syscall_desc syscalls[] = {
|
||||
{ "mknod", ACTION_MKNOD, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} },
|
||||
{ "mknodat", ACTION_MKNODAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} },
|
||||
{ "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } },
|
||||
#ifdef HAS_BINDAT
|
||||
{ "bindat", ACTION_BINDAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } },
|
||||
#endif
|
||||
{ "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } },
|
||||
#ifdef HAS_CONNECTAT
|
||||
{ "connectat", ACTION_CONNECTAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } },
|
||||
#endif
|
||||
{ "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
{ "fchmod", ACTION_FCHMOD, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NONE } },
|
||||
#ifdef HAS_LCHMOD
|
||||
@ -732,6 +744,22 @@ call_syscall(struct syscall_desc *scall, char *argv[])
|
||||
rval = bind(rval, (struct sockaddr *)&sunx, sizeof(sunx));
|
||||
break;
|
||||
}
|
||||
#ifdef HAS_BINDAT
|
||||
case ACTION_BINDAT:
|
||||
{
|
||||
struct sockaddr_un sunx;
|
||||
|
||||
sunx.sun_family = AF_UNIX;
|
||||
strncpy(sunx.sun_path, STR(1), sizeof(sunx.sun_path) - 1);
|
||||
sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0';
|
||||
rval = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (rval < 0)
|
||||
break;
|
||||
rval = bindat(NUM(0), rval, (struct sockaddr *)&sunx,
|
||||
sizeof(sunx));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case ACTION_CONNECT:
|
||||
{
|
||||
struct sockaddr_un sunx;
|
||||
@ -745,6 +773,22 @@ call_syscall(struct syscall_desc *scall, char *argv[])
|
||||
rval = connect(rval, (struct sockaddr *)&sunx, sizeof(sunx));
|
||||
break;
|
||||
}
|
||||
#ifdef HAS_CONNECTAT
|
||||
case ACTION_CONNECTAT:
|
||||
{
|
||||
struct sockaddr_un sunx;
|
||||
|
||||
sunx.sun_family = AF_UNIX;
|
||||
strncpy(sunx.sun_path, STR(1), sizeof(sunx.sun_path) - 1);
|
||||
sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0';
|
||||
rval = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (rval < 0)
|
||||
break;
|
||||
rval = connectat(NUM(0), rval, (struct sockaddr *)&sunx,
|
||||
sizeof(sunx));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case ACTION_CHMOD:
|
||||
rval = chmod(STR(0), (mode_t)NUM(1));
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user