mirror of
https://github.com/bol-van/zapret.git
synced 2025-01-06 08:20:34 +05:00
nfqws: remove : in perror
This commit is contained in:
parent
ae9a72f5b0
commit
7d917d8334
@ -105,13 +105,13 @@ bool set_socket_buffers(int fd, int rcvbuf, int sndbuf)
|
|||||||
DLOG("set_socket_buffers fd=%d rcvbuf=%d sndbuf=%d\n",fd,rcvbuf,sndbuf)
|
DLOG("set_socket_buffers fd=%d rcvbuf=%d sndbuf=%d\n",fd,rcvbuf,sndbuf)
|
||||||
if (rcvbuf && setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(int)) <0)
|
if (rcvbuf && setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(int)) <0)
|
||||||
{
|
{
|
||||||
perror("setsockopt (SO_RCVBUF): ");
|
perror("setsockopt (SO_RCVBUF)");
|
||||||
close(fd);
|
close(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (sndbuf && setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(int)) <0)
|
if (sndbuf && setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(int)) <0)
|
||||||
{
|
{
|
||||||
perror("setsockopt (SO_SNDBUF): ");
|
perror("setsockopt (SO_SNDBUF)");
|
||||||
close(fd);
|
close(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
26
nfq/nfqws.c
26
nfq/nfqws.c
@ -216,36 +216,36 @@ static int nfq_main()
|
|||||||
printf("opening library handle\n");
|
printf("opening library handle\n");
|
||||||
h = nfq_open();
|
h = nfq_open();
|
||||||
if (!h) {
|
if (!h) {
|
||||||
perror("nfq_open() :");
|
perror("nfq_open()");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("unbinding existing nf_queue handler for AF_INET (if any)\n");
|
printf("unbinding existing nf_queue handler for AF_INET (if any)\n");
|
||||||
if (nfq_unbind_pf(h, AF_INET) < 0) {
|
if (nfq_unbind_pf(h, AF_INET) < 0) {
|
||||||
perror("nfq_unbind_pf() :");
|
perror("nfq_unbind_pf()");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("binding nfnetlink_queue as nf_queue handler for AF_INET\n");
|
printf("binding nfnetlink_queue as nf_queue handler for AF_INET\n");
|
||||||
if (nfq_bind_pf(h, AF_INET) < 0) {
|
if (nfq_bind_pf(h, AF_INET) < 0) {
|
||||||
perror("nfq_bind_pf() :");
|
perror("nfq_bind_pf()");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("binding this socket to queue '%u'\n", params.qnum);
|
printf("binding this socket to queue '%u'\n", params.qnum);
|
||||||
qh = nfq_create_queue(h, params.qnum, &nfq_cb, ¶ms);
|
qh = nfq_create_queue(h, params.qnum, &nfq_cb, ¶ms);
|
||||||
if (!qh) {
|
if (!qh) {
|
||||||
perror("nfq_create_queue() :");
|
perror("nfq_create_queue()");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("setting copy_packet mode\n");
|
printf("setting copy_packet mode\n");
|
||||||
if (nfq_set_mode(qh, NFQNL_COPY_PACKET, 0xffff) < 0) {
|
if (nfq_set_mode(qh, NFQNL_COPY_PACKET, 0xffff) < 0) {
|
||||||
perror("can't set packet_copy mode :");
|
perror("can't set packet_copy mode");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
if (nfq_set_queue_maxlen(qh, Q_MAXLEN) < 0) {
|
if (nfq_set_queue_maxlen(qh, Q_MAXLEN) < 0) {
|
||||||
perror("can't set queue maxlen : ");
|
perror("can't set queue maxlen");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
// accept packets if they cant be handled
|
// accept packets if they cant be handled
|
||||||
@ -325,13 +325,13 @@ static int dvt_main()
|
|||||||
printf("creating divert4 socket\n");
|
printf("creating divert4 socket\n");
|
||||||
fd[0] = socket(AF_INET, SOCK_RAW, IPPROTO_DIVERT);
|
fd[0] = socket(AF_INET, SOCK_RAW, IPPROTO_DIVERT);
|
||||||
if (fd[0] == -1) {
|
if (fd[0] == -1) {
|
||||||
perror("socket (DIVERT4): ");
|
perror("socket (DIVERT4)");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
printf("binding divert4 socket\n");
|
printf("binding divert4 socket\n");
|
||||||
if (bind(fd[0], (struct sockaddr*)&bp4, sizeof(bp4)) < 0)
|
if (bind(fd[0], (struct sockaddr*)&bp4, sizeof(bp4)) < 0)
|
||||||
{
|
{
|
||||||
perror("bind (DIVERT4): ");
|
perror("bind (DIVERT4)");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
if (!set_socket_buffers(fd[0],Q_RCVBUF,Q_SNDBUF))
|
if (!set_socket_buffers(fd[0],Q_RCVBUF,Q_SNDBUF))
|
||||||
@ -350,13 +350,13 @@ static int dvt_main()
|
|||||||
printf("creating divert6 socket\n");
|
printf("creating divert6 socket\n");
|
||||||
fd[1] = socket(AF_INET6, SOCK_RAW, IPPROTO_DIVERT);
|
fd[1] = socket(AF_INET6, SOCK_RAW, IPPROTO_DIVERT);
|
||||||
if (fd[1] == -1) {
|
if (fd[1] == -1) {
|
||||||
perror("socket (DIVERT6): ");
|
perror("socket (DIVERT6)");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
printf("binding divert6 socket\n");
|
printf("binding divert6 socket\n");
|
||||||
if (bind(fd[1], (struct sockaddr*)&bp6, sizeof(bp6)) < 0)
|
if (bind(fd[1], (struct sockaddr*)&bp6, sizeof(bp6)) < 0)
|
||||||
{
|
{
|
||||||
perror("bind (DIVERT6): ");
|
perror("bind (DIVERT6)");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
fdct++;
|
fdct++;
|
||||||
@ -391,7 +391,7 @@ static int dvt_main()
|
|||||||
dohup();
|
dohup();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
perror("select: ");
|
perror("select");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
for(i=0;i<fdct;i++)
|
for(i=0;i<fdct;i++)
|
||||||
@ -402,7 +402,7 @@ static int dvt_main()
|
|||||||
rd = recvfrom(fd[i], buf, sizeof(buf), 0, (struct sockaddr*)&sa_from, &socklen);
|
rd = recvfrom(fd[i], buf, sizeof(buf), 0, (struct sockaddr*)&sa_from, &socklen);
|
||||||
if (rd<0)
|
if (rd<0)
|
||||||
{
|
{
|
||||||
perror("recvfrom: ");
|
perror("recvfrom");
|
||||||
goto exiterr;
|
goto exiterr;
|
||||||
}
|
}
|
||||||
else if (rd>0)
|
else if (rd>0)
|
||||||
@ -416,7 +416,7 @@ static int dvt_main()
|
|||||||
DLOG(ppr==pass ? "packet: id=%u reinject unmodified\n" : "packet: id=%u reinject modified\n", id);
|
DLOG(ppr==pass ? "packet: id=%u reinject unmodified\n" : "packet: id=%u reinject modified\n", id);
|
||||||
wr = sendto(fd[i], buf, rd, 0, (struct sockaddr*)&sa_from, socklen);
|
wr = sendto(fd[i], buf, rd, 0, (struct sockaddr*)&sa_from, socklen);
|
||||||
if (wr<0)
|
if (wr<0)
|
||||||
perror("reinject sendto: ");
|
perror("reinject sendto");
|
||||||
else if (wr!=rd)
|
else if (wr!=rd)
|
||||||
fprintf(stderr,"reinject sendto: not all data was reinjected. received %zd, sent %zd\n", rd, wr);
|
fprintf(stderr,"reinject sendto: not all data was reinjected. received %zd, sent %zd\n", rd, wr);
|
||||||
break;
|
break;
|
||||||
|
10
nfq/sec.c
10
nfq/sec.c
@ -87,24 +87,24 @@ bool droproot(uid_t uid, gid_t gid)
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
if (prctl(PR_SET_KEEPCAPS, 1L))
|
if (prctl(PR_SET_KEEPCAPS, 1L))
|
||||||
{
|
{
|
||||||
perror("prctl(PR_SET_KEEPCAPS): ");
|
perror("prctl(PR_SET_KEEPCAPS)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// drop all SGIDs
|
// drop all SGIDs
|
||||||
if (setgroups(0,NULL))
|
if (setgroups(0,NULL))
|
||||||
{
|
{
|
||||||
perror("setgroups: ");
|
perror("setgroups");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (setgid(gid))
|
if (setgid(gid))
|
||||||
{
|
{
|
||||||
perror("setgid: ");
|
perror("setgid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (setuid(uid))
|
if (setuid(uid))
|
||||||
{
|
{
|
||||||
perror("setuid: ");
|
perror("setuid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -137,7 +137,7 @@ void daemonize()
|
|||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
{
|
{
|
||||||
perror("fork: ");
|
perror("fork");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
else if (pid != 0)
|
else if (pid != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user