summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/qemu
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-15 17:59:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-16 15:40:11 +0100
commit609fc157180778025b2f416736839a7935217731 (patch)
tree493497d19c1d82190bcf39a18c7dfe8031f60d0e /meta/recipes-devtools/qemu
parent3ee077f991e7810bf515783058be940a4b8f6adc (diff)
downloadpoky-609fc157180778025b2f416736839a7935217731.tar.gz
runqemu/qemu-helper: Drop tunctl
ip tuntap provides the functionality that we obtained from tunctl. We only needed tunctl when ifconfig was more available than ip. That isn't the case now so we can drop tunctl and all the hoops we need to jump through to build and provide it. (From OE-Core rev: 2abfbca690ff00cb58ce08a65cde006578ee3de9) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/qemu')
-rw-r--r--meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb7
-rw-r--r--meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb9
-rw-r--r--meta/recipes-devtools/qemu/qemu-helper/tunctl.c158
3 files changed, 4 insertions, 170 deletions
diff --git a/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb b/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb
index 2a5bcfb909..b100659a8c 100644
--- a/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb
+++ b/meta/recipes-devtools/qemu/nativesdk-qemu-helper_1.0.bb
@@ -6,8 +6,7 @@ RDEPENDS:${PN} = "nativesdk-qemu nativesdk-unfs3 nativesdk-pseudo \
6 6
7PR = "r9" 7PR = "r9"
8 8
9LIC_FILES_CHKSUM = "file://${WORKDIR}/tunctl.c;endline=4;md5=ff3a09996bc5fff6bc5d4e0b4c28f999 \ 9LIC_FILES_CHKSUM = "file://${COREBASE}/scripts/runqemu;beginline=5;endline=10;md5=ac2b489a58739c7628a2604698db5e7f"
10 file://${COREBASE}/scripts/runqemu;beginline=5;endline=10;md5=ac2b489a58739c7628a2604698db5e7f"
11 10
12 11
13SRC_URI = "file://${COREBASE}/scripts/runqemu \ 12SRC_URI = "file://${COREBASE}/scripts/runqemu \
@@ -18,7 +17,6 @@ SRC_URI = "file://${COREBASE}/scripts/runqemu \
18 file://${COREBASE}/scripts/oe-find-native-sysroot \ 17 file://${COREBASE}/scripts/oe-find-native-sysroot \
19 file://${COREBASE}/scripts/runqemu-extract-sdk \ 18 file://${COREBASE}/scripts/runqemu-extract-sdk \
20 file://${COREBASE}/scripts/runqemu-export-rootfs \ 19 file://${COREBASE}/scripts/runqemu-export-rootfs \
21 file://tunctl.c \
22 " 20 "
23 21
24S = "${WORKDIR}" 22S = "${WORKDIR}"
@@ -26,12 +24,11 @@ S = "${WORKDIR}"
26inherit nativesdk 24inherit nativesdk
27 25
28do_compile() { 26do_compile() {
29 ${CC} tunctl.c -o tunctl 27 :
30} 28}
31 29
32do_install() { 30do_install() {
33 install -d ${D}${bindir} 31 install -d ${D}${bindir}
34 install -m 0755 ${WORKDIR}${COREBASE}/scripts/oe-* ${D}${bindir}/ 32 install -m 0755 ${WORKDIR}${COREBASE}/scripts/oe-* ${D}${bindir}/
35 install -m 0755 ${WORKDIR}${COREBASE}/scripts/runqemu* ${D}${bindir}/ 33 install -m 0755 ${WORKDIR}${COREBASE}/scripts/runqemu* ${D}${bindir}/
36 install tunctl ${D}${bindir}/
37} 34}
diff --git a/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb b/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb
index 6053b71717..4d64ea4b93 100644
--- a/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb
+++ b/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb
@@ -3,25 +3,20 @@ LICENSE = "GPL-2.0-only"
3RDEPENDS:${PN} = "qemu-system-native" 3RDEPENDS:${PN} = "qemu-system-native"
4PR = "r1" 4PR = "r1"
5 5
6LIC_FILES_CHKSUM = "file://${WORKDIR}/tunctl.c;endline=4;md5=ff3a09996bc5fff6bc5d4e0b4c28f999" 6LIC_FILES_CHKSUM = "file://${WORKDIR}/qemu-oe-bridge-helper.c;endline=4;md5=ae00a3bab86f2caaa8462eacda77f4d7"
7 7
8SRC_URI = "\ 8SRC_URI = "file://qemu-oe-bridge-helper.c"
9 file://tunctl.c \
10 file://qemu-oe-bridge-helper.c \
11 "
12 9
13S = "${WORKDIR}" 10S = "${WORKDIR}"
14 11
15inherit native 12inherit native
16 13
17do_compile() { 14do_compile() {
18 ${CC} ${CFLAGS} ${LDFLAGS} -Wall tunctl.c -o tunctl
19 ${CC} ${CFLAGS} ${LDFLAGS} -Wall qemu-oe-bridge-helper.c -o qemu-oe-bridge-helper 15 ${CC} ${CFLAGS} ${LDFLAGS} -Wall qemu-oe-bridge-helper.c -o qemu-oe-bridge-helper
20} 16}
21 17
22do_install() { 18do_install() {
23 install -d ${D}${bindir} 19 install -d ${D}${bindir}
24 install tunctl ${D}${bindir}/
25 install qemu-oe-bridge-helper ${D}${bindir}/ 20 install qemu-oe-bridge-helper ${D}${bindir}/
26} 21}
27 22
diff --git a/meta/recipes-devtools/qemu/qemu-helper/tunctl.c b/meta/recipes-devtools/qemu/qemu-helper/tunctl.c
deleted file mode 100644
index d745dd06cb..0000000000
--- a/meta/recipes-devtools/qemu/qemu-helper/tunctl.c
+++ /dev/null
@@ -1,158 +0,0 @@
1/* Copyright 2002 Jeff Dike
2 * Licensed under the GPL
3 */
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8#include <errno.h>
9#include <fcntl.h>
10#include <unistd.h>
11#include <pwd.h>
12#include <grp.h>
13#include <net/if.h>
14#include <sys/ioctl.h>
15#include <linux/if_tun.h>
16
17/* TUNSETGROUP appeared in 2.6.23 */
18#ifndef TUNSETGROUP
19#define TUNSETGROUP _IOW('T', 206, int)
20#endif
21
22static void Usage(char *name, int status)
23{
24 fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] "
25 "[-f tun-clone-device]\n", name);
26 fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n",
27 name);
28 fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems"
29 " use\n/dev/misc/net/tun instead\n\n");
30 fprintf(stderr, "-b will result in brief output (just the device name)\n");
31 exit(status);
32}
33
34int main(int argc, char **argv)
35{
36 struct ifreq ifr;
37 struct passwd *pw;
38 struct group *gr;
39 uid_t owner = -1;
40 gid_t group = -1;
41 int tap_fd, opt, delete = 0, brief = 0;
42 char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end;
43
44 while((opt = getopt(argc, argv, "bd:f:t:u:g:h")) > 0){
45 switch(opt) {
46 case 'b':
47 brief = 1;
48 break;
49 case 'd':
50 delete = 1;
51 tun = optarg;
52 break;
53 case 'f':
54 file = optarg;
55 break;
56 case 'u':
57 pw = getpwnam(optarg);
58 if(pw != NULL){
59 owner = pw->pw_uid;
60 break;
61 }
62 owner = strtol(optarg, &end, 0);
63 if(*end != '\0'){
64 fprintf(stderr, "'%s' is neither a username nor a numeric uid.\n",
65 optarg);
66 Usage(name, 1);
67 }
68 break;
69 case 'g':
70 gr = getgrnam(optarg);
71 if(gr != NULL){
72 group = gr->gr_gid;
73 break;
74 }
75 group = strtol(optarg, &end, 0);
76 if(*end != '\0'){
77 fprintf(stderr, "'%s' is neither a groupname nor a numeric group.\n",
78 optarg);
79 Usage(name, 1);
80 }
81 break;
82
83 case 't':
84 tun = optarg;
85 break;
86 case 'h':
87 Usage(name, 0);
88 break;
89 default:
90 Usage(name, 1);
91 }
92 }
93
94 argv += optind;
95 argc -= optind;
96
97 if(argc > 0)
98 Usage(name, 1);
99
100 if((tap_fd = open(file, O_RDWR)) < 0){
101 fprintf(stderr, "Failed to open '%s' : ", file);
102 perror("");
103 exit(1);
104 }
105
106 memset(&ifr, 0, sizeof(ifr));
107
108 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
109 strncpy(ifr.ifr_name, tun, sizeof(ifr.ifr_name) - 1);
110 if(ioctl(tap_fd, TUNSETIFF, (void *) &ifr) < 0){
111 perror("TUNSETIFF");
112 exit(1);
113 }
114
115 if(delete){
116 if(ioctl(tap_fd, TUNSETPERSIST, 0) < 0){
117 perror("disabling TUNSETPERSIST");
118 exit(1);
119 }
120 printf("Set '%s' nonpersistent\n", ifr.ifr_name);
121 }
122 else {
123 /* emulate behaviour prior to TUNSETGROUP */
124 if(owner == -1 && group == -1) {
125 owner = geteuid();
126 }
127
128 if(owner != -1) {
129 if(ioctl(tap_fd, TUNSETOWNER, owner) < 0){
130 perror("TUNSETOWNER");
131 exit(1);
132 }
133 }
134 if(group != -1) {
135 if(ioctl(tap_fd, TUNSETGROUP, group) < 0){
136 perror("TUNSETGROUP");
137 exit(1);
138 }
139 }
140
141 if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){
142 perror("enabling TUNSETPERSIST");
143 exit(1);
144 }
145
146 if(brief)
147 printf("%s\n", ifr.ifr_name);
148 else {
149 printf("Set '%s' persistent and owned by", ifr.ifr_name);
150 if(owner != -1)
151 printf(" uid %d", owner);
152 if(group != -1)
153 printf(" gid %d", group);
154 printf("\n");
155 }
156 }
157 return(0);
158}