diff options
| -rw-r--r-- | meta/recipes-core/busybox/busybox/0001-Switch-to-POSIX-utmpx-API.patch | 388 | ||||
| -rw-r--r-- | meta/recipes-core/busybox/busybox_1.23.2.bb | 1 |
2 files changed, 389 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-Switch-to-POSIX-utmpx-API.patch b/meta/recipes-core/busybox/busybox/0001-Switch-to-POSIX-utmpx-API.patch new file mode 100644 index 0000000000..1d299eec9b --- /dev/null +++ b/meta/recipes-core/busybox/busybox/0001-Switch-to-POSIX-utmpx-API.patch | |||
| @@ -0,0 +1,388 @@ | |||
| 1 | From 86a7f18f211af1abda5c855d2674b0fcb53de524 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | ||
| 3 | Date: Thu, 2 Apr 2015 23:03:46 +0200 | ||
| 4 | Subject: [PATCH] *: Switch to POSIX utmpx API | ||
| 5 | |||
| 6 | UTMP is SVID legacy, UTMPX is mandated by POSIX. | ||
| 7 | |||
| 8 | Glibc and uClibc have identical layout of UTMP and UTMPX, both of these | ||
| 9 | libc treat _PATH_UTMPX as _PATH_UTMP so from a user-perspective nothing | ||
| 10 | changes except the names of the API entrypoints. | ||
| 11 | |||
| 12 | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | ||
| 13 | --- | ||
| 14 | Upstream-Status: Backport | ||
| 15 | |||
| 16 | coreutils/who.c | 8 ++++---- | ||
| 17 | include/libbb.h | 2 +- | ||
| 18 | init/halt.c | 4 ++-- | ||
| 19 | libbb/utmp.c | 44 ++++++++++++++++++++++---------------------- | ||
| 20 | miscutils/last.c | 8 ++++---- | ||
| 21 | miscutils/last_fancy.c | 16 ++++++++++------ | ||
| 22 | miscutils/runlevel.c | 12 ++++++------ | ||
| 23 | miscutils/wall.c | 8 ++++---- | ||
| 24 | procps/uptime.c | 6 +++--- | ||
| 25 | 9 files changed, 56 insertions(+), 52 deletions(-) | ||
| 26 | |||
| 27 | diff --git a/coreutils/who.c b/coreutils/who.c | ||
| 28 | index f955ce6..8337212 100644 | ||
| 29 | --- a/coreutils/who.c | ||
| 30 | +++ b/coreutils/who.c | ||
| 31 | @@ -73,7 +73,7 @@ static void idle_string(char *str6, time_t t) | ||
| 32 | int who_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 33 | int who_main(int argc UNUSED_PARAM, char **argv) | ||
| 34 | { | ||
| 35 | - struct utmp *ut; | ||
| 36 | + struct utmpx *ut; | ||
| 37 | unsigned opt; | ||
| 38 | int do_users = (ENABLE_USERS && (!ENABLE_WHO || applet_name[0] == 'u')); | ||
| 39 | const char *fmt = "%s"; | ||
| 40 | @@ -83,8 +83,8 @@ int who_main(int argc UNUSED_PARAM, char **argv) | ||
| 41 | if (opt & 2) // -H | ||
| 42 | printf("USER\t\tTTY\t\tIDLE\tTIME\t\t HOST\n"); | ||
| 43 | |||
| 44 | - setutent(); | ||
| 45 | - while ((ut = getutent()) != NULL) { | ||
| 46 | + setutxent(); | ||
| 47 | + while ((ut = getutxent()) != NULL) { | ||
| 48 | if (ut->ut_user[0] | ||
| 49 | && ((opt & 1) || ut->ut_type == USER_PROCESS) | ||
| 50 | ) { | ||
| 51 | @@ -126,6 +126,6 @@ int who_main(int argc UNUSED_PARAM, char **argv) | ||
| 52 | if (do_users) | ||
| 53 | bb_putchar('\n'); | ||
| 54 | if (ENABLE_FEATURE_CLEAN_UP) | ||
| 55 | - endutent(); | ||
| 56 | + endutxent(); | ||
| 57 | return EXIT_SUCCESS; | ||
| 58 | } | ||
| 59 | diff --git a/include/libbb.h b/include/libbb.h | ||
| 60 | index 26b6868..0f8363b 100644 | ||
| 61 | --- a/include/libbb.h | ||
| 62 | +++ b/include/libbb.h | ||
| 63 | @@ -84,7 +84,7 @@ | ||
| 64 | # include <selinux/av_permissions.h> | ||
| 65 | #endif | ||
| 66 | #if ENABLE_FEATURE_UTMP | ||
| 67 | -# include <utmp.h> | ||
| 68 | +# include <utmpx.h> | ||
| 69 | #endif | ||
| 70 | #if ENABLE_LOCALE_SUPPORT | ||
| 71 | # include <locale.h> | ||
| 72 | diff --git a/init/halt.c b/init/halt.c | ||
| 73 | index 7974adb..ad12d91 100644 | ||
| 74 | --- a/init/halt.c | ||
| 75 | +++ b/init/halt.c | ||
| 76 | @@ -74,7 +74,7 @@ | ||
| 77 | |||
| 78 | static void write_wtmp(void) | ||
| 79 | { | ||
| 80 | - struct utmp utmp; | ||
| 81 | + struct utmpx utmp; | ||
| 82 | struct utsname uts; | ||
| 83 | /* "man utmp" says wtmp file should *not* be created automagically */ | ||
| 84 | /*if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) { | ||
| 85 | @@ -88,7 +88,7 @@ static void write_wtmp(void) | ||
| 86 | utmp.ut_line[0] = '~'; utmp.ut_line[1] = '~'; /* = strcpy(utmp.ut_line, "~~"); */ | ||
| 87 | uname(&uts); | ||
| 88 | safe_strncpy(utmp.ut_host, uts.release, sizeof(utmp.ut_host)); | ||
| 89 | - updwtmp(bb_path_wtmp_file, &utmp); | ||
| 90 | + updwtmpx(bb_path_wtmp_file, &utmp); | ||
| 91 | } | ||
| 92 | #else | ||
| 93 | #define write_wtmp() ((void)0) | ||
| 94 | diff --git a/libbb/utmp.c b/libbb/utmp.c | ||
| 95 | index 8ad9ba2..bd07670 100644 | ||
| 96 | --- a/libbb/utmp.c | ||
| 97 | +++ b/libbb/utmp.c | ||
| 98 | @@ -16,7 +16,7 @@ static void touch(const char *filename) | ||
| 99 | |||
| 100 | void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) | ||
| 101 | { | ||
| 102 | - struct utmp utent; | ||
| 103 | + struct utmpx utent; | ||
| 104 | char *id; | ||
| 105 | unsigned width; | ||
| 106 | |||
| 107 | @@ -45,17 +45,17 @@ void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, con | ||
| 108 | tty_name += 3; | ||
| 109 | strncpy(id, tty_name, width); | ||
| 110 | |||
| 111 | - touch(_PATH_UTMP); | ||
| 112 | - //utmpname(_PATH_UTMP); | ||
| 113 | - setutent(); | ||
| 114 | + touch(_PATH_UTMPX); | ||
| 115 | + //utmpxname(_PATH_UTMPX); | ||
| 116 | + setutxent(); | ||
| 117 | /* Append new one (hopefully, unless we collide on ut_id) */ | ||
| 118 | - pututline(&utent); | ||
| 119 | - endutent(); | ||
| 120 | + pututxline(&utent); | ||
| 121 | + endutxent(); | ||
| 122 | |||
| 123 | #if ENABLE_FEATURE_WTMP | ||
| 124 | /* "man utmp" says wtmp file should *not* be created automagically */ | ||
| 125 | /*touch(bb_path_wtmp_file);*/ | ||
| 126 | - updwtmp(bb_path_wtmp_file, &utent); | ||
| 127 | + updwtmpx(bb_path_wtmp_file, &utent); | ||
| 128 | #endif | ||
| 129 | } | ||
| 130 | |||
| 131 | @@ -64,17 +64,17 @@ void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, con | ||
| 132 | */ | ||
| 133 | void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) | ||
| 134 | { | ||
| 135 | - struct utmp utent; | ||
| 136 | - struct utmp *utp; | ||
| 137 | + struct utmpx utent; | ||
| 138 | + struct utmpx *utp; | ||
| 139 | |||
| 140 | - touch(_PATH_UTMP); | ||
| 141 | - //utmpname(_PATH_UTMP); | ||
| 142 | - setutent(); | ||
| 143 | + touch(_PATH_UTMPX); | ||
| 144 | + //utmpxname(_PATH_UTMPX); | ||
| 145 | + setutxent(); | ||
| 146 | |||
| 147 | /* Did init/getty/telnetd/sshd/... create an entry for us? | ||
| 148 | * It should be (new_type-1), but we'd also reuse | ||
| 149 | * any other potentially stale xxx_PROCESS entry */ | ||
| 150 | - while ((utp = getutent()) != NULL) { | ||
| 151 | + while ((utp = getutxent()) != NULL) { | ||
| 152 | if (utp->ut_pid == pid | ||
| 153 | // && ut->ut_line[0] | ||
| 154 | && utp->ut_id[0] /* must have nonzero id */ | ||
| 155 | @@ -88,25 +88,25 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const | ||
| 156 | /* Stale record. Nuke hostname */ | ||
| 157 | memset(utp->ut_host, 0, sizeof(utp->ut_host)); | ||
| 158 | } | ||
| 159 | - /* NB: pututline (see later) searches for matching utent | ||
| 160 | - * using getutid(utent) - we must not change ut_id | ||
| 161 | + /* NB: pututxline (see later) searches for matching utxent | ||
| 162 | + * using getutxid(utent) - we must not change ut_id | ||
| 163 | * if we want *exactly this* record to be overwritten! | ||
| 164 | */ | ||
| 165 | break; | ||
| 166 | } | ||
| 167 | } | ||
| 168 | - //endutent(); - no need, pututline can deal with (and actually likes) | ||
| 169 | + //endutxent(); - no need, pututxline can deal with (and actually likes) | ||
| 170 | //the situation when utmp file is positioned on found record | ||
| 171 | |||
| 172 | if (!utp) { | ||
| 173 | if (new_type != DEAD_PROCESS) | ||
| 174 | write_new_utmp(pid, new_type, tty_name, username, hostname); | ||
| 175 | else | ||
| 176 | - endutent(); | ||
| 177 | + endutxent(); | ||
| 178 | return; | ||
| 179 | } | ||
| 180 | |||
| 181 | - /* Make a copy. We can't use *utp, pututline's internal getutid | ||
| 182 | + /* Make a copy. We can't use *utp, pututxline's internal getutxid | ||
| 183 | * will overwrite it before it is used! */ | ||
| 184 | utent = *utp; | ||
| 185 | |||
| 186 | @@ -120,14 +120,14 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const | ||
| 187 | utent.ut_tv.tv_sec = time(NULL); | ||
| 188 | |||
| 189 | /* Update, or append new one */ | ||
| 190 | - //setutent(); | ||
| 191 | - pututline(&utent); | ||
| 192 | - endutent(); | ||
| 193 | + //setutxent(); | ||
| 194 | + pututxline(&utent); | ||
| 195 | + endutxent(); | ||
| 196 | |||
| 197 | #if ENABLE_FEATURE_WTMP | ||
| 198 | /* "man utmp" says wtmp file should *not* be created automagically */ | ||
| 199 | /*touch(bb_path_wtmp_file);*/ | ||
| 200 | - updwtmp(bb_path_wtmp_file, &utent); | ||
| 201 | + updwtmpx(bb_path_wtmp_file, &utent); | ||
| 202 | #endif | ||
| 203 | } | ||
| 204 | |||
| 205 | diff --git a/miscutils/last.c b/miscutils/last.c | ||
| 206 | index a144c7e..6d8b584 100644 | ||
| 207 | --- a/miscutils/last.c | ||
| 208 | +++ b/miscutils/last.c | ||
| 209 | @@ -32,21 +32,21 @@ | ||
| 210 | |||
| 211 | #if defined UT_LINESIZE \ | ||
| 212 | && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)) | ||
| 213 | -#error struct utmp member char[] size(s) have changed! | ||
| 214 | +#error struct utmpx member char[] size(s) have changed! | ||
| 215 | #elif defined __UT_LINESIZE \ | ||
| 216 | && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 64) || (__UT_HOSTSIZE != 256)) | ||
| 217 | -#error struct utmp member char[] size(s) have changed! | ||
| 218 | +#error struct utmpx member char[] size(s) have changed! | ||
| 219 | #endif | ||
| 220 | |||
| 221 | #if EMPTY != 0 || RUN_LVL != 1 || BOOT_TIME != 2 || NEW_TIME != 3 || \ | ||
| 222 | OLD_TIME != 4 | ||
| 223 | -#error Values for the ut_type field of struct utmp changed | ||
| 224 | +#error Values for the ut_type field of struct utmpx changed | ||
| 225 | #endif | ||
| 226 | |||
| 227 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 228 | int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | ||
| 229 | { | ||
| 230 | - struct utmp ut; | ||
| 231 | + struct utmpx ut; | ||
| 232 | int n, file = STDIN_FILENO; | ||
| 233 | time_t t_tmp; | ||
| 234 | off_t pos; | ||
| 235 | diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c | ||
| 236 | index 16ed9e9..8194e31 100644 | ||
| 237 | --- a/miscutils/last_fancy.c | ||
| 238 | +++ b/miscutils/last_fancy.c | ||
| 239 | @@ -22,6 +22,10 @@ | ||
| 240 | #define HEADER_LINE_WIDE "USER", "TTY", \ | ||
| 241 | INET6_ADDRSTRLEN, INET6_ADDRSTRLEN, "HOST", "LOGIN", " TIME", "" | ||
| 242 | |||
| 243 | +#if !defined __UT_LINESIZE && defined UT_LINESIZE | ||
| 244 | +# define __UT_LINESIZE UT_LINESIZE | ||
| 245 | +#endif | ||
| 246 | + | ||
| 247 | enum { | ||
| 248 | NORMAL, | ||
| 249 | LOGGED, | ||
| 250 | @@ -39,7 +43,7 @@ enum { | ||
| 251 | |||
| 252 | #define show_wide (option_mask32 & LAST_OPT_W) | ||
| 253 | |||
| 254 | -static void show_entry(struct utmp *ut, int state, time_t dur_secs) | ||
| 255 | +static void show_entry(struct utmpx *ut, int state, time_t dur_secs) | ||
| 256 | { | ||
| 257 | unsigned days, hours, mins; | ||
| 258 | char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; | ||
| 259 | @@ -104,7 +108,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) | ||
| 260 | duration_str); | ||
| 261 | } | ||
| 262 | |||
| 263 | -static int get_ut_type(struct utmp *ut) | ||
| 264 | +static int get_ut_type(struct utmpx *ut) | ||
| 265 | { | ||
| 266 | if (ut->ut_line[0] == '~') { | ||
| 267 | if (strcmp(ut->ut_user, "shutdown") == 0) { | ||
| 268 | @@ -142,7 +146,7 @@ static int get_ut_type(struct utmp *ut) | ||
| 269 | return ut->ut_type; | ||
| 270 | } | ||
| 271 | |||
| 272 | -static int is_runlevel_shutdown(struct utmp *ut) | ||
| 273 | +static int is_runlevel_shutdown(struct utmpx *ut) | ||
| 274 | { | ||
| 275 | if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) { | ||
| 276 | return 1; | ||
| 277 | @@ -154,7 +158,7 @@ static int is_runlevel_shutdown(struct utmp *ut) | ||
| 278 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 279 | int last_main(int argc UNUSED_PARAM, char **argv) | ||
| 280 | { | ||
| 281 | - struct utmp ut; | ||
| 282 | + struct utmpx ut; | ||
| 283 | const char *filename = _PATH_WTMP; | ||
| 284 | llist_t *zlist; | ||
| 285 | off_t pos; | ||
| 286 | @@ -242,9 +246,9 @@ int last_main(int argc UNUSED_PARAM, char **argv) | ||
| 287 | { | ||
| 288 | llist_t *el, *next; | ||
| 289 | for (el = zlist; el; el = next) { | ||
| 290 | - struct utmp *up = (struct utmp *)el->data; | ||
| 291 | + struct utmpx *up = (struct utmpx *)el->data; | ||
| 292 | next = el->link; | ||
| 293 | - if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { | ||
| 294 | + if (strncmp(up->ut_line, ut.ut_line, __UT_LINESIZE) == 0) { | ||
| 295 | if (show) { | ||
| 296 | show_entry(&ut, NORMAL, up->ut_tv.tv_sec); | ||
| 297 | show = 0; | ||
| 298 | diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c | ||
| 299 | index 76231df..8558db8 100644 | ||
| 300 | --- a/miscutils/runlevel.c | ||
| 301 | +++ b/miscutils/runlevel.c | ||
| 302 | @@ -29,19 +29,19 @@ | ||
| 303 | int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 304 | int runlevel_main(int argc UNUSED_PARAM, char **argv) | ||
| 305 | { | ||
| 306 | - struct utmp *ut; | ||
| 307 | + struct utmpx *ut; | ||
| 308 | char prev; | ||
| 309 | |||
| 310 | - if (argv[1]) utmpname(argv[1]); | ||
| 311 | + if (argv[1]) utmpxname(argv[1]); | ||
| 312 | |||
| 313 | - setutent(); | ||
| 314 | - while ((ut = getutent()) != NULL) { | ||
| 315 | + setutxent(); | ||
| 316 | + while ((ut = getutxent()) != NULL) { | ||
| 317 | if (ut->ut_type == RUN_LVL) { | ||
| 318 | prev = ut->ut_pid / 256; | ||
| 319 | if (prev == 0) prev = 'N'; | ||
| 320 | printf("%c %c\n", prev, ut->ut_pid % 256); | ||
| 321 | if (ENABLE_FEATURE_CLEAN_UP) | ||
| 322 | - endutent(); | ||
| 323 | + endutxent(); | ||
| 324 | return 0; | ||
| 325 | } | ||
| 326 | } | ||
| 327 | @@ -49,6 +49,6 @@ int runlevel_main(int argc UNUSED_PARAM, char **argv) | ||
| 328 | puts("unknown"); | ||
| 329 | |||
| 330 | if (ENABLE_FEATURE_CLEAN_UP) | ||
| 331 | - endutent(); | ||
| 332 | + endutxent(); | ||
| 333 | return 1; | ||
| 334 | } | ||
| 335 | diff --git a/miscutils/wall.c b/miscutils/wall.c | ||
| 336 | index bb709ee..50658f4 100644 | ||
| 337 | --- a/miscutils/wall.c | ||
| 338 | +++ b/miscutils/wall.c | ||
| 339 | @@ -32,7 +32,7 @@ | ||
| 340 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 341 | int wall_main(int argc UNUSED_PARAM, char **argv) | ||
| 342 | { | ||
| 343 | - struct utmp *ut; | ||
| 344 | + struct utmpx *ut; | ||
| 345 | char *msg; | ||
| 346 | int fd; | ||
| 347 | |||
| 348 | @@ -46,8 +46,8 @@ int wall_main(int argc UNUSED_PARAM, char **argv) | ||
| 349 | msg = xmalloc_read(fd, NULL); | ||
| 350 | if (ENABLE_FEATURE_CLEAN_UP && argv[1]) | ||
| 351 | close(fd); | ||
| 352 | - setutent(); | ||
| 353 | - while ((ut = getutent()) != NULL) { | ||
| 354 | + setutxent(); | ||
| 355 | + while ((ut = getutxent()) != NULL) { | ||
| 356 | char *line; | ||
| 357 | if (ut->ut_type != USER_PROCESS) | ||
| 358 | continue; | ||
| 359 | @@ -56,7 +56,7 @@ int wall_main(int argc UNUSED_PARAM, char **argv) | ||
| 360 | free(line); | ||
| 361 | } | ||
| 362 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
| 363 | - endutent(); | ||
| 364 | + endutxent(); | ||
| 365 | free(msg); | ||
| 366 | } | ||
| 367 | return EXIT_SUCCESS; | ||
| 368 | diff --git a/procps/uptime.c b/procps/uptime.c | ||
| 369 | index 778812a..149bae6 100644 | ||
| 370 | --- a/procps/uptime.c | ||
| 371 | +++ b/procps/uptime.c | ||
| 372 | @@ -81,10 +81,10 @@ int uptime_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | ||
| 373 | |||
| 374 | #if ENABLE_FEATURE_UPTIME_UTMP_SUPPORT | ||
| 375 | { | ||
| 376 | - struct utmp *ut; | ||
| 377 | + struct utmpx *ut; | ||
| 378 | unsigned users = 0; | ||
| 379 | - while ((ut = getutent()) != NULL) { | ||
| 380 | - if ((ut->ut_type == USER_PROCESS) && (ut->ut_name[0] != '\0')) | ||
| 381 | + while ((ut = getutxent()) != NULL) { | ||
| 382 | + if ((ut->ut_type == USER_PROCESS) && (ut->ut_user[0] != '\0')) | ||
| 383 | users++; | ||
| 384 | } | ||
| 385 | printf(", %u users", users); | ||
| 386 | -- | ||
| 387 | 2.5.1 | ||
| 388 | |||
diff --git a/meta/recipes-core/busybox/busybox_1.23.2.bb b/meta/recipes-core/busybox/busybox_1.23.2.bb index e4d9f9718d..5e027326c2 100644 --- a/meta/recipes-core/busybox/busybox_1.23.2.bb +++ b/meta/recipes-core/busybox/busybox_1.23.2.bb | |||
| @@ -30,6 +30,7 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ | |||
| 30 | file://login-utilities.cfg \ | 30 | file://login-utilities.cfg \ |
| 31 | file://recognize_connmand.patch \ | 31 | file://recognize_connmand.patch \ |
| 32 | file://busybox-cross-menuconfig.patch \ | 32 | file://busybox-cross-menuconfig.patch \ |
| 33 | file://0001-Switch-to-POSIX-utmpx-API.patch \ | ||
| 33 | file://0001-ifconfig-fix-double-free-fatal-error-in-INET_sprint.patch \ | 34 | file://0001-ifconfig-fix-double-free-fatal-error-in-INET_sprint.patch \ |
| 34 | file://0001-chown-fix-help-text.patch \ | 35 | file://0001-chown-fix-help-text.patch \ |
| 35 | file://mount-via-label.cfg \ | 36 | file://mount-via-label.cfg \ |
