fix(guix): add dedicated build step to compile and run loopback bind helper before python server

This commit is contained in:
vxtls 2026-03-13 21:58:50 -04:00
parent 96c2cfbb98
commit 4324f23d48
3 changed files with 75 additions and 0 deletions

View file

@ -0,0 +1,53 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <sys/socket.h>
int main(void) {
int fd;
struct ifreq ifr;
struct sockaddr_in addr;
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
perror("socket");
return 1;
}
memset(&ifr, 0, sizeof(ifr));
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
if (inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr) != 1) {
perror("inet_pton");
close(fd);
return 1;
}
strncpy(ifr.ifr_name, "lo", IFNAMSIZ - 1);
memcpy(&ifr.ifr_addr, &addr, sizeof(addr));
if (ioctl(fd, SIOCSIFADDR, &ifr) < 0) {
perror("ioctl(SIOCSIFADDR)");
close(fd);
return 1;
}
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
perror("ioctl(SIOCGIFFLAGS)");
close(fd);
return 1;
}
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
perror("ioctl(SIOCSIFFLAGS)");
close(fd);
return 1;
}
close(fd);
return 0;
}