From nobody Tue Jun 08 17:25:30 2021 X-Original-To: standards@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BB8E2F7F6E7 for ; Tue, 8 Jun 2021 17:25:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fzxvt4sDKz3sm0 for ; Tue, 8 Jun 2021 17:25:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F74352C6 for ; Tue, 8 Jun 2021 17:25:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 158HPUJF010080 for ; Tue, 8 Jun 2021 17:25:30 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 158HPUpr010079 for standards@FreeBSD.org; Tue, 8 Jun 2021 17:25:30 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 256486] uname(1) doesn't strip whitespace from -v like uname(3) Date: Tue, 08 Jun 2021 17:25:30 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: nabijaczleweli@nabijaczleweli.xyz X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Standards compliance List-Archive: https://lists.freebsd.org/archives/freebsd-standards List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-standards@freebsd.org X-BeenThere: freebsd-standards@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D256486 Bug ID: 256486 Summary: uname(1) doesn't strip whitespace from -v like uname(3) Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: nabijaczleweli@nabijaczleweli.xyz Consider the following, where ./out/cmd/uname -v just prints uname(3).versi= on: [build@build ~/voreutils]$ sysctl -b kern.version FreeBSD 13.0-RELEASE-p1 #0: Wed May 26 22:15:09 UTC 2021 root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GEN= ERIC [build@build ~/voreutils]$ sysctl -b kern.version | hexdump -C 00000000 46 72 65 65 42 53 44 20 31 33 2e 30 2d 52 45 4c |FreeBSD 13.0-R= EL| 00000010 45 41 53 45 2d 70 31 20 23 30 3a 20 57 65 64 20 |EASE-p1 #0: We= d | 00000020 4d 61 79 20 32 36 20 32 32 3a 31 35 3a 30 39 20 |May 26 22:15:0= 9 | 00000030 55 54 43 20 32 30 32 31 0a 20 20 20 20 72 6f 6f |UTC 2021. r= oo| 00000040 74 40 61 6d 64 36 34 2d 62 75 69 6c 64 65 72 2e |t@amd64-builde= r.| 00000050 64 61 65 6d 6f 6e 6f 6c 6f 67 79 2e 6e 65 74 3a |daemonology.ne= t:| 00000060 2f 75 73 72 2f 6f 62 6a 2f 75 73 72 2f 73 72 63 |/usr/obj/usr/s= rc| 00000070 2f 61 6d 64 36 34 2e 61 6d 64 36 34 2f 73 79 73 |/amd64.amd64/s= ys| 00000080 2f 47 45 4e 45 52 49 43 0a 00 |/GENERIC..| 0000008a [build@build ~/voreutils]$ uname -v FreeBSD 13.0-RELEASE-p1 #0: Wed May 26 22:15:09 UTC 2021=20=20=20=20 root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC [build@build ~/voreutils]$ ./out/cmd/uname -v FreeBSD 13.0-RELEASE-p1 #0: Wed May 26 22:15:09 UTC 2021=20=20=20=20 root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC [build@build ~/voreutils]$ uname -v | hexdump -C 00000000 46 72 65 65 42 53 44 20 31 33 2e 30 2d 52 45 4c |FreeBSD 13.0-R= EL| 00000010 45 41 53 45 2d 70 31 20 23 30 3a 20 57 65 64 20 |EASE-p1 #0: We= d | 00000020 4d 61 79 20 32 36 20 32 32 3a 31 35 3a 30 39 20 |May 26 22:15:0= 9 | 00000030 55 54 43 20 32 30 32 31 20 20 20 20 20 72 6f 6f |UTC 2021 r= oo| 00000040 74 40 61 6d 64 36 34 2d 62 75 69 6c 64 65 72 2e |t@amd64-builde= r.| 00000050 64 61 65 6d 6f 6e 6f 6c 6f 67 79 2e 6e 65 74 3a |daemonology.ne= t:| 00000060 2f 75 73 72 2f 6f 62 6a 2f 75 73 72 2f 73 72 63 |/usr/obj/usr/s= rc| 00000070 2f 61 6d 64 36 34 2e 61 6d 64 36 34 2f 73 79 73 |/amd64.amd64/s= ys| 00000080 2f 47 45 4e 45 52 49 43 20 0a |/GENERIC .| 0000008a [build@build ~/voreutils]$ ./out/cmd/uname -v | hexdump -C 00000000 46 72 65 65 42 53 44 20 31 33 2e 30 2d 52 45 4c |FreeBSD 13.0-R= EL| 00000010 45 41 53 45 2d 70 31 20 23 30 3a 20 57 65 64 20 |EASE-p1 #0: We= d | 00000020 4d 61 79 20 32 36 20 32 32 3a 31 35 3a 30 39 20 |May 26 22:15:0= 9 | 00000030 55 54 43 20 32 30 32 31 20 20 20 20 20 72 6f 6f |UTC 2021 r= oo| 00000040 74 40 61 6d 64 36 34 2d 62 75 69 6c 64 65 72 2e |t@amd64-builde= r.| 00000050 64 61 65 6d 6f 6e 6f 6c 6f 67 79 2e 6e 65 74 3a |daemonology.ne= t:| 00000060 2f 75 73 72 2f 6f 62 6a 2f 75 73 72 2f 73 72 63 |/usr/obj/usr/s= rc| 00000070 2f 61 6d 64 36 34 2e 61 6d 64 36 34 2f 73 79 73 |/amd64.amd64/s= ys| 00000080 2f 47 45 4e 45 52 49 43 0a |/GENERIC.| 00000089 This is backed by uname(1) source: NATIVE_SYSCTL2_GET(version, CTL_KERN, KERN_VERSION) { size_t n; char *p; p =3D NATIVE_BUFFER; n =3D NATIVE_LENGTH; for (; n--; ++p) if (*p =3D=3D '\n' || *p =3D=3D '\t') *p =3D ' '; } NATIVE_SET; And uname(3) source: if ((p =3D getenv("UNAME_v"))) strlcpy(q, p, namesize); else { /* * The version may have newlines in it, turn them into * spaces. */ mib[1] =3D KERN_VERSION; len =3D namesize; oerrno =3D errno; if (sysctl(mib, 2, q, &len, NULL, 0) =3D=3D -1) { if (errno =3D=3D ENOMEM) errno =3D oerrno; else rval =3D -1; } q[namesize - 1] =3D '\0'; for (p =3D q; len--; ++p) { if (*p =3D=3D '\n' || *p =3D=3D '\t') { if (len > 1) *p =3D ' '; else *p =3D '\0'; } } } q +=3D namesize; As you can see, the code is almost identical, except for the part where uname(3) strips the final newline instead of making it a space. This breaks POSIX compatibility, which states (quoth IEEE Std 1003.1-2017): By default, the uname utility shall write the operating system name to standard output. When options are specified, symbols representing one or mo= re system characteristics shall be written to the standard output. The format = and contents of the symbols are implementation-defined. On systems conforming to the System Interfaces volume of POSIX.1-2017, the symbols written shall be those supported by the uname() function as defined in the System Interfaces volume of POSIX.1-2017. and: If the -a option is specified, the output shall be a single line of the following form: "%s %s %s %s %s\n", , , , , Additional implementation-defined symbols may be written; all such symbols shall be written at the end of the line of output before the . If options are specified to select different combinations of the symbols, o= nly those symbols shall be written, in the order shown above for the -a option.= If a symbol is not selected for writing, its corresponding trailing characters also shall not be written. --=20 You are receiving this mail because: You are the assignee for the bug.=