TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / wsutil / os_version_info.c
blob7e9daa0568b238bae44c12e44113d4b6b3733aef
1 /* os_version_info.c
2 * Routines to report operating system version information
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #include "config.h"
13 #include <wsutil/os_version_info.h>
15 #include <string.h>
16 #include <errno.h>
18 #ifdef HAVE_SYS_UTSNAME_H
19 #include <sys/utsname.h>
20 #endif
22 #ifdef HAVE_MACOS_FRAMEWORKS
23 #include <CoreFoundation/CoreFoundation.h>
24 #include <wsutil/cfutils.h>
25 #endif
27 #include <wsutil/unicode-utils.h>
30 * Handles the rather elaborate process of getting OS version information
31 * from macOS (we want the macOS version, not the Darwin version, the latter
32 * being easy to get with uname()).
34 #ifdef HAVE_MACOS_FRAMEWORKS
37 * Fetch a string, as a UTF-8 C string, from a dictionary, given a key.
39 static char *
40 get_string_from_dictionary(CFPropertyListRef dict, CFStringRef key)
42 CFStringRef cfstring;
44 cfstring = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)dict,
45 (const void *)key);
46 if (cfstring == NULL)
47 return NULL;
48 if (CFGetTypeID(cfstring) != CFStringGetTypeID()) {
49 /* It isn't a string. Punt. */
50 return NULL;
52 return CFString_to_C_string(cfstring);
56 * Get the macOS version information, and append it to the GString.
57 * Return true if we succeed, false if we fail.
59 * XXX - this gives the OS name as "Mac OS X" even if Apple called/calls
60 * it "OS X" or "macOS".
62 static bool
63 get_macos_version_info(GString *str)
65 static const UInt8 server_version_plist_path[] =
66 "/System/Library/CoreServices/ServerVersion.plist";
67 static const UInt8 system_version_plist_path[] =
68 "/System/Library/CoreServices/SystemVersion.plist";
69 CFURLRef version_plist_file_url;
70 CFReadStreamRef version_plist_stream;
71 CFDictionaryRef version_dict;
72 char *string;
75 * On macOS, report the macOS version number as the OS, and put
76 * the Darwin information in parentheses.
78 * Alas, Gestalt() is deprecated in Mountain Lion, so the build
79 * fails if you treat deprecation warnings as fatal. I don't
80 * know of any replacement API, so we fall back on reading
81 * /System/Library/CoreServices/ServerVersion.plist if it
82 * exists, otherwise /System/Library/CoreServices/SystemVersion.plist,
83 * and using ProductUserVisibleVersion. We also get the build
84 * version from ProductBuildVersion and the product name from
85 * ProductName.
87 version_plist_file_url = CFURLCreateFromFileSystemRepresentation(NULL,
88 server_version_plist_path, sizeof server_version_plist_path - 1,
89 false);
90 if (version_plist_file_url == NULL)
91 return false;
92 version_plist_stream = CFReadStreamCreateWithFile(NULL,
93 version_plist_file_url);
94 CFRelease(version_plist_file_url);
95 if (version_plist_stream == NULL)
96 return false;
97 if (!CFReadStreamOpen(version_plist_stream)) {
98 CFRelease(version_plist_stream);
101 * Try SystemVersion.plist.
103 version_plist_file_url = CFURLCreateFromFileSystemRepresentation(NULL,
104 system_version_plist_path, sizeof system_version_plist_path - 1,
105 false);
106 if (version_plist_file_url == NULL)
107 return false;
108 version_plist_stream = CFReadStreamCreateWithFile(NULL,
109 version_plist_file_url);
110 CFRelease(version_plist_file_url);
111 if (version_plist_stream == NULL)
112 return false;
113 if (!CFReadStreamOpen(version_plist_stream)) {
114 CFRelease(version_plist_stream);
115 return false;
118 #ifdef HAVE_CFPROPERTYLISTCREATEWITHSTREAM
119 version_dict = (CFDictionaryRef)CFPropertyListCreateWithStream(NULL,
120 version_plist_stream, 0, kCFPropertyListImmutable,
121 NULL, NULL);
122 #else
123 version_dict = (CFDictionaryRef)CFPropertyListCreateFromStream(NULL,
124 version_plist_stream, 0, kCFPropertyListImmutable,
125 NULL, NULL);
126 #endif
127 if (version_dict == NULL) {
128 CFRelease(version_plist_stream);
129 return false;
131 if (CFGetTypeID(version_dict) != CFDictionaryGetTypeID()) {
132 /* This is *supposed* to be a dictionary. Punt. */
133 CFRelease(version_dict);
134 CFReadStreamClose(version_plist_stream);
135 CFRelease(version_plist_stream);
136 return false;
138 /* Get the product name string. */
139 string = get_string_from_dictionary(version_dict,
140 CFSTR("ProductName"));
141 if (string == NULL) {
142 CFRelease(version_dict);
143 CFReadStreamClose(version_plist_stream);
144 CFRelease(version_plist_stream);
145 return false;
147 g_string_append_printf(str, "%s", string);
148 g_free(string);
150 /* Get the OS version string. */
151 string = get_string_from_dictionary(version_dict,
152 CFSTR("ProductUserVisibleVersion"));
153 if (string == NULL) {
154 CFRelease(version_dict);
155 CFReadStreamClose(version_plist_stream);
156 CFRelease(version_plist_stream);
157 return false;
159 g_string_append_printf(str, " %s", string);
160 g_free(string);
162 /* Get the build string */
163 string = get_string_from_dictionary(version_dict,
164 CFSTR("ProductBuildVersion"));
165 if (string == NULL) {
166 CFRelease(version_dict);
167 CFReadStreamClose(version_plist_stream);
168 CFRelease(version_plist_stream);
169 return false;
171 g_string_append_printf(str, ", build %s", string);
172 g_free(string);
173 CFRelease(version_dict);
174 CFReadStreamClose(version_plist_stream);
175 CFRelease(version_plist_stream);
176 return true;
178 #endif
180 #ifdef _WIN32
181 typedef LONG (WINAPI * RtlGetVersionProc) (OSVERSIONINFOEX *);
182 #ifndef STATUS_SUCCESS
183 #define STATUS_SUCCESS 0
184 #endif
185 #include <stdlib.h>
188 * Determine whether it's 32-bit or 64-bit Windows based on the
189 * instruction set; this only tests for the instruction sets
190 * that we currently support for Windows, it doesn't bother with MIPS,
191 * PowerPC, Alpha, or IA-64, nor does it bother wieth 32-bit ARM.
193 static void
194 add_os_bitsize(GString *str, SYSTEM_INFO *system_info)
196 switch (system_info->wProcessorArchitecture) {
197 case PROCESSOR_ARCHITECTURE_AMD64:
198 #ifdef PROCESSOR_ARCHITECTURE_ARM64
199 case PROCESSOR_ARCHITECTURE_ARM64:
200 #endif
201 g_string_append(str, "64-bit ");
202 break;
203 case PROCESSOR_ARCHITECTURE_INTEL:
204 g_string_append(str, "32-bit ");
205 break;
206 default:
207 break;
212 * Test whether the OS an "NT Workstation" version, meaning "not server".
214 static bool
215 is_nt_workstation(OSVERSIONINFOEX *win_version_info)
217 return win_version_info->wProductType == VER_NT_WORKSTATION;
219 #endif // _WIN32
222 * Get the OS version, and append it to the GString
224 void
225 get_os_version_info(GString *str)
227 #if defined(_WIN32)
229 OSVERSIONINFOEX win_version_info = {0};
230 RtlGetVersionProc RtlGetVersionP = 0;
231 LONG version_status = STATUS_ENTRYPOINT_NOT_FOUND; // Any nonzero value should work.
234 * We want the major and minor Windows version along with other
235 * information. GetVersionEx provides this, but is deprecated.
236 * We use RtlGetVersion instead, which requires a bit of extra
237 * effort.
240 HMODULE ntdll_module = LoadLibrary(_T("ntdll.dll"));
241 if (ntdll_module) {
242 DIAG_OFF(cast-function-type)
243 RtlGetVersionP = (RtlGetVersionProc) GetProcAddress(ntdll_module, "RtlGetVersion");
244 DIAG_ON(cast-function-type)
247 if (RtlGetVersionP) {
248 win_version_info.dwOSVersionInfoSize = sizeof(win_version_info);
249 version_status = RtlGetVersionP(&win_version_info);
252 if (ntdll_module) {
253 FreeLibrary(ntdll_module);
256 if (version_status != STATUS_SUCCESS) {
258 * XXX - get the failure reason.
260 g_string_append(str, "unknown Windows version");
261 return;
264 SYSTEM_INFO system_info;
265 memset(&system_info, '\0', sizeof system_info);
267 * Look for and use the GetNativeSystemInfo() function to get the
268 * correct processor architecture even when running 32-bit Wireshark
269 * in WOW64 (x86 emulation on 64-bit Windows).
271 * However, the documentation for GetNativeSystemInfo() says
273 * If the function is called from an x86 or x64 application
274 * running on a 64-bit system that does not have an Intel64
275 * or x64 processor (such as ARM64), it will return information
276 * as if the system is x86 only if x86 emulation is supported
277 * (or x64 if x64 emulation is also supported).
279 * so it appears that it will *not* return the correct processor
280 * architecture if running x86-64 Wireshark on ARM64 with
281 * x86-64 emulation - it will presumably say "x86-64", not "ARM64".
283 * So we use it to say "32-bit" or "64-bit", but we don't use
284 * it to say "N-bit x86" or "N-bit ARM".
286 * It Would Be Nice if there were some way to report that
287 * Wireshark is running in emulation on an ARM64 system;
288 * that might be important if, for example, a user is
289 * reporting a capture problem, as there currently isn't
290 * a version of Npcap that can support x86-64 programs on
291 * an ARM64 system.
293 GetNativeSystemInfo(&system_info);
295 switch (win_version_info.dwPlatformId) {
297 case VER_PLATFORM_WIN32s:
298 /* Shyeah, right. */
299 g_string_append_printf(str, "Windows 3.1 with Win32s");
300 break;
302 case VER_PLATFORM_WIN32_WINDOWS:
304 * Windows OT.
306 * https://nsis-dev.github.io/NSIS-Forums/html/t-128527.html
308 * claims that
310 * HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
312 * has a key ProductName, at least in Windows M3, the
313 * value of that key appears to be an OS product name.
315 switch (win_version_info.dwMajorVersion) {
317 case 4:
318 /* 3 cheers for Microsoft marketing! */
319 switch (win_version_info.dwMinorVersion) {
321 case 0:
322 g_string_append_printf(str, "Windows 95");
323 break;
325 case 10:
326 g_string_append_printf(str, "Windows 98");
327 break;
329 case 90:
330 g_string_append_printf(str, "Windows Me");
331 break;
333 default:
334 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
335 win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
336 break;
338 break;
340 default:
341 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
342 win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
343 break;
345 break;
347 case VER_PLATFORM_WIN32_NT:
349 * Windows NT.
351 * https://stackoverflow.com/a/19778234/16139739
353 * claims that
355 * HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion
357 * has a key ProductName that is "present for Windows XP
358 * and aboeve[sic]". The value of that key gives a
359 * "product name"...
361 * ...at least until Windows 11, which it insists is
362 * Windows 10. So we don't bother with it. (It may
363 * indicate whether it's Home or Pro or..., but that's
364 * not worth the effort of fixing the "Windows 11 is
365 * Windows 10" nonsense.)
367 * https://patents.google.com/patent/EP1517235A2/en
369 * is a Microsoft patent that mentions the
370 * BrandingFormatString() routine, and seems to suggest
371 * that it dates back to at least Windows XP.
373 * https://dennisbabkin.com/blog/?t=how-to-tell-the-real-version-of-windows-your-app-is-running-on
375 * says that routine is in an undocumented winbrand.dll DLL,
376 * but is used by Microsoft's own code to put the OS
377 * product name into messages. It, unlike ProductName,
378 * appears to make a distinction between Windows 10 and
379 * Windows 11, and, when handed the string "%WINDOWS_LONG%",
380 * gives the same edition decoration that I suspect
381 * ProductName does.
383 switch (win_version_info.dwMajorVersion) {
385 case 3:
386 case 4:
387 /* NT 3.x and 4.x. */
388 g_string_append_printf(str, "Windows NT %lu.%lu",
389 win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
390 break;
392 case 5:
394 * W2K, WXP, and their server versions.
395 * 3 cheers for Microsoft marketing!
397 switch (win_version_info.dwMinorVersion) {
399 case 0:
400 g_string_append_printf(str, "Windows 2000");
401 break;
403 case 1:
404 g_string_append_printf(str, "Windows XP");
405 break;
407 case 2:
408 if (is_nt_workstation(&win_version_info) &&
409 (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {
410 g_string_append_printf(str, "Windows XP Professional x64 Edition");
411 } else {
412 g_string_append_printf(str, "Windows Server 2003");
413 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
414 g_string_append_printf(str, " x64 Edition");
416 break;
418 default:
419 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
420 win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
421 break;
423 break;
425 case 6: {
427 * Vista, W7, W8, W8.1, and their server versions.
429 add_os_bitsize(str, &system_info);
430 switch (win_version_info.dwMinorVersion) {
431 case 0:
432 g_string_append_printf(str, is_nt_workstation(&win_version_info) ? "Windows Vista" : "Windows Server 2008");
433 break;
434 case 1:
435 g_string_append_printf(str, is_nt_workstation(&win_version_info) ? "Windows 7" : "Windows Server 2008 R2");
436 break;
437 case 2:
438 g_string_append_printf(str, is_nt_workstation(&win_version_info) ? "Windows 8" : "Windows Server 2012");
439 break;
440 case 3:
441 g_string_append_printf(str, is_nt_workstation(&win_version_info) ? "Windows 8.1" : "Windows Server 2012 R2");
442 break;
443 default:
444 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
445 win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
446 break;
448 break;
449 } /* case 6 */
451 case 10: {
453 * W10, W11, and their server versions.
455 TCHAR ReleaseId[10];
456 DWORD ridSize = _countof(ReleaseId);
458 add_os_bitsize(str, &system_info);
459 switch (win_version_info.dwMinorVersion) {
460 case 0:
461 /* List of BuildNumber from https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
462 * and https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information */
463 if (is_nt_workstation(&win_version_info)) {
464 if (win_version_info.dwBuildNumber < 10240) {
465 /* XXX - W10 builds before 10240? */
466 g_string_append_printf(str, "Windows");
467 } else if (win_version_info.dwBuildNumber < 22000){
468 /* W10 builds sstart at 10240 and end before 22000 */
469 g_string_append_printf(str, "Windows 10");
470 } else {
471 /* Builds 22000 and later are W11 (until there's W12...). */
472 g_string_append_printf(str, "Windows 11");
474 } else {
475 switch (win_version_info.dwBuildNumber) {
476 case 14393:
477 g_string_append_printf(str, "Windows Server 2016");
478 break;
479 case 17763:
480 g_string_append_printf(str, "Windows Server 2019");
481 break;
482 case 20348:
483 g_string_append_printf(str, "Windows Server 2022");
484 break;
485 default:
486 g_string_append_printf(str, "Windows Server");
487 break;
492 * Windows 10 and 11 have had multiple
493 * releases, with different build numbers.
495 * The build number *could* be used to
496 * determine the release string, but
497 * that would require a table of releases
498 * and strings, and that would have to
499 * get updated whenever a new release
500 * comes out, and that seems to happen
501 * twice a year these days.
503 * The good news is that, under
505 * HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion
507 * there are two keys, DisplayVersion and
508 * ReleaseId. If DisplayVersion is present,
509 * it's a string that gives the release
510 * string; if not, ReleaseId gives the
511 * release string.
513 * The DisplayVersion value is currently
514 * of the form YYHN, where YY is the
515 * last two digits of the year, H stands
516 * for "half", and N is the half of the
517 * year in which it came out.
519 * The ReleaseId is just a numeric string
520 * and for all the YYHN releases, it's
521 * stuck at the same value.
523 * Note further that
525 * https://github.com/nvaccess/nvda/blob/master/source/winVersion.py
527 * has a comment claiming that
529 * From Version 1511 (build 10586), release
530 * Id/display version comes from Windows
531 * Registry.
532 * However there are builds with no release
533 * name (Version 1507/10240) or releases
534 * with different builds.
535 * Look these up first before asking
536 * Windows Registry.
538 * "Look these up first" means "look them
539 * up in a table that goes from
541 * 10240: Windows 10 1507
543 * to
545 * 22621: Windows 11 22H2
547 * and also includes
549 * 20348: Windows Server 2022
551 * I'm not sure why any Windows 10 builds
552 * after 10240 are in the table; what does
553 * "releases with different builds" mean?
554 * does it mean that those particular
555 * builds have bogus ReleaseId or
556 * DisplayVersion values? Those builds
557 * appear to be official release builds
558 * for W10/W11, according to the table
559 * in
561 * https://en.wikipedia.org/wiki/Windows_NT
563 * so, if those are all necessary, why
564 * should ReleaseId or DisplayVersion be
565 * trusted at all?
567 * As for the Windows Server 2022 entry,
568 * is that just because that script doesn't
569 * bother checking for "workstation" vs.
570 * "server"?
572 if (RegGetValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
573 L"DisplayVersion", RRF_RT_REG_SZ, NULL, &ReleaseId, &ridSize) == ERROR_SUCCESS) {
574 g_string_append_printf(str, " (%s)", utf_16to8(ReleaseId));
576 else if (RegGetValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
577 L"ReleaseId", RRF_RT_REG_SZ, NULL, &ReleaseId, &ridSize) == ERROR_SUCCESS) {
578 g_string_append_printf(str, " (%s)", utf_16to8(ReleaseId));
580 break;
581 default:
582 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
583 win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
584 break;
586 break;
587 } /* case 10 */
589 default:
590 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
591 win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
592 break;
593 } /* info.dwMajorVersion */
594 break;
596 default:
597 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
598 win_version_info.dwPlatformId, win_version_info.dwMajorVersion, win_version_info.dwMinorVersion);
599 break;
601 if (win_version_info.szCSDVersion[0] != '\0')
602 g_string_append_printf(str, " %s", utf_16to8(win_version_info.szCSDVersion));
603 g_string_append_printf(str, ", build %lu", win_version_info.dwBuildNumber);
604 #elif defined(HAVE_SYS_UTSNAME_H)
605 struct utsname name;
607 * We have <sys/utsname.h>, so we assume we have "uname()".
609 if (uname(&name) < 0) {
610 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
611 g_strerror(errno));
612 return;
615 if (strcmp(name.sysname, "AIX") == 0) {
617 * Yay, IBM! Thanks for doing something different
618 * from most of the other UNIXes out there, and
619 * making "name.version" apparently be the major
620 * version number and "name.release" be the minor
621 * version number.
623 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
624 name.release);
625 } else {
627 * XXX - get "version" on any other platforms?
629 * On Digital/Tru64 UNIX, it's something unknown.
630 * On Solaris, it's some kind of build information.
631 * On HP-UX, it appears to be some sort of subrevision
632 * thing.
633 * On *BSD and Darwin/macOS, it's a long string giving
634 * a build date, config file name, etc., etc., etc..
636 #ifdef HAVE_MACOS_FRAMEWORKS
638 * On macOS, report the macOS version number as the OS
639 * version if we can, and put the Darwin information
640 * in parentheses.
642 if (get_macos_version_info(str)) {
643 /* Success - append the Darwin information. */
644 g_string_append_printf(str, " (%s %s)", name.sysname, name.release);
645 } else {
646 /* Failure - just use the Darwin information. */
647 g_string_append_printf(str, "%s %s", name.sysname, name.release);
649 #else /* HAVE_MACOS_FRAMEWORKS */
651 * XXX - on Linux, are there any APIs to get the distribution
652 * name and version number? I think some distributions have
653 * that.
655 * At least on Linux Standard Base-compliant distributions,
656 * there's an "lsb_release" command. However:
658 * http://forums.fedoraforum.org/showthread.php?t=220885
660 * seems to suggest that if you don't have the redhat-lsb
661 * package installed, you don't have lsb_release, and that
662 * /etc/fedora-release has the release information on
663 * Fedora.
665 * http://linux.die.net/man/1/lsb_release
667 * suggests that there's an /etc/distrib-release file, but
668 * it doesn't indicate whether "distrib" is literally
669 * "distrib" or is the name for the distribution, and
670 * also speaks of an /etc/debian_version file.
672 * "lsb_release" apparently parses /etc/lsb-release, which
673 * has shell-style assignments, assigning to, among other
674 * values, DISTRIB_ID (distributor/distribution name),
675 * DISTRIB_RELEASE (release number of the distribution),
676 * DISTRIB_DESCRIPTION (*might* be name followed by version,
677 * but the manpage for lsb_release seems to indicate that's
678 * not guaranteed), and DISTRIB_CODENAME (code name, e.g.
679 * "licentious" for the Ubuntu Licentious Lemur release).
680 * the lsb_release man page also speaks of the distrib-release
681 * file, but Debian doesn't have one, and Ubuntu 7's
682 * lsb_release command doesn't look for one.
684 * I've seen references to /etc/redhat-release as well.
686 * See also
688 * http://bugs.python.org/issue1322
690 * http://www.novell.com/coolsolutions/feature/11251.html
692 * http://linuxmafia.com/faq/Admin/release-files.html
694 * and the Lib/Platform.py file in recent Python 2.x
695 * releases.
697 * And then there's /etc/os-release:
699 * https://0pointer.de/blog/projects/os-release
701 * which, apparently, is something that all distributions
702 * with systemd have, which seems to mean "most distributions"
703 * these days. It also has a list of several of the assorted
704 * *other* such files that various distributions have.
706 * Maybe look at what pre-version-43 systemd does? 43
707 * removed support for the old files, but I guess that
708 * means older versions *did* support them:
710 * https://lists.freedesktop.org/archives/systemd-devel/2012-February/004475.html
712 * At least on my Ubuntu 7 system, /etc/debian_version
713 * doesn't contain anything interesting (just some Debian
714 * codenames). It does have /etc/lsb-release. My Ubuntu
715 * 22.04 system has /etc/lsb-release and /etc/os-release.
717 * My Fedora 9 system has /etc/fedora-release, with
718 * /etc/redhat-release and /etc/system-release as symlinks
719 * to it. They all just contain a one-line relase
720 * description. My Fedora 38 system has that, plus
721 * /etc/os-release.
723 * A quick Debian 3.1a installation I did has only
724 * /etc/debian_version. My Debian 11.3 system has
725 * /etc/os-release.
727 * See
729 * https://gist.github.com/natefoo/814c5bf936922dad97ff
731 * for descriptions of what some versions of some
732 * distributions offer.
734 * So maybe have a table of files to try, with each
735 * entry having a pathname, a pointer to a file parser
736 * routine, and a pointer to a string giving a
737 * parameter name passed to that routine, with entries
738 * for:
740 * /etc/os-release, regular parser, "PRETTY_NAME"
741 * /etc/lsb-release, regular parser, "DISTRIB_DESCRIPTION"
742 * /etc/system-release, first line parser, NULL
743 * /etc/redhat-release, first line parser, NULL
744 * /etc/fedora-release, first line parser, NULL
745 * /etc/centos-release, first line parser, NULL
746 * /etc/debian_version, first line parser, "Debian"
747 * /etc/SuSE-release, first line parser, NULL
748 * /etc/slackware-version:, first line parser, NULL
749 * /etc/gentoo-release, first line parser, NULL
750 * /etc/antix-version, first line parser, NULL
752 * Each line is tried in order. If the open fails, go to
753 * the next one. If the open succeeds but the parser
754 * fails, close the file and go on to the next one.
756 * The regular parser parses files of the form
757 * <param>="value". It's passed the value of <param>
758 * for which to look; if not found, it fails.
760 * The first line parser reads the first line of the file.
761 * If a string is passed to it, it constructs a distribution
762 * name string by concatenating the parameter, a space,
763 * and the contents of that line (with the newline removed),
764 * otherwise it constructs it from the contents of the line.
766 * Fall back on just "Linux" if nothing works.
768 * Then use the uname() information to indicate what
769 * kernel version the machine is running.
771 * XXX - for Gentoo, PRETTY_NAME might not give a version,
772 * so fall back on /etc/gentoo-release? Gentoo is
773 * a rolling-release distribution, so what *is* the
774 * significance of the contnets of /etc/gentoo-release?
776 * XXX - MX appears to be a Debian-based distribution
777 * whose /etc/os-release gives its Debian version and
778 * whose /etc/mx-version and /etc/antix-version give
779 * the MX version. Are there any other Debian derivatives
780 * that do this? (The Big One calls itself "Ubuntu"
781 * in PRETTY_NAME.)
783 * XXX - use ID_LIKE in /etc/os-release to check for,
784 * for example, Debian-like distributions, e.g. when
785 * suggesting how to give dumpcap capture privileges?
787 g_string_append_printf(str, "%s %s", name.sysname, name.release);
788 #endif /* HAVE_MACOS_FRAMEWORKS */
790 #else
791 g_string_append(str, "an unknown OS");
792 #endif
796 * Editor modelines - https://www.wireshark.org/tools/modelines.html
798 * Local variables:
799 * c-basic-offset: 8
800 * tab-width: 8
801 * indent-tabs-mode: t
802 * End:
804 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
805 * :indentSize=8:tabSize=8:noTabs=false: