]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #16512 from keszybz/offline-passwd-altfiles
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 18 Jul 2020 21:46:05 +0000 (06:46 +0900)
committerGitHub <noreply@github.com>
Sat, 18 Jul 2020 21:46:05 +0000 (06:46 +0900)
Support alternate passwd/group locations in tmpfiles

hwdb.d/60-autosuspend.hwdb
hwdb.d/parse_hwdb.py
man/systemd-initctl.service.xml
meson.build
src/udev/udev-builtin-hwdb.c
tools/make-autosuspend-rules.py
units/meson.build

index 0de49afa6cd4c2305689bfe693e498eb1a410548..e742a33ea69e8eb4176994dd6c61b074ef1d4c8a 100644 (file)
 usb:v058Fp9540*
  ID_AUTOSUSPEND=1
 
+#########################################
+# QEMU
+#########################################
+
+# Emulated USB HID devices
+usb:v0627p0001:*QEMU USB Keyboard*
+usb:v0627p0001:*QEMU USB Mouse*
+usb:v0627p0001:*QEMU USB Tablet*
+ ID_AUTOSUSPEND=1
+
 #########################################
 # Wacom
 #########################################
index 8e1b5fdafa4c600279f8c3a4288bef31610cdd82..025133416f6e23c23ce64f1dfad9bc96f0d84a76 100755 (executable)
@@ -79,6 +79,9 @@ GENERAL_MATCHES = {'acpi',
                    'OUI',
                    }
 
+def upperhex_word(length):
+    return Word(nums + 'ABCDEF', exact=length)
+
 @lru_cache()
 def hwdb_grammar():
     ParserElement.setDefaultWhitespaceChars('')
@@ -87,7 +90,7 @@ def hwdb_grammar():
                 for category, conn in TYPES.items())
 
     matchline_typed = Combine(prefix + Word(printables + ' ' + '®'))
-    matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables))
+    matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables + ' ' + '®'))
     matchline = (matchline_typed | matchline_general) + EOL
 
     propertyline = (White(' ', exact=1).suppress() +
@@ -180,8 +183,27 @@ def parse(fname):
         return []
     return [convert_properties(g) for g in parsed.GROUPS]
 
-def check_match_uniqueness(groups):
+def check_matches(groups):
     matches = sum((group[0] for group in groups), [])
+
+    # This is a partial check. The other cases could be also done, but those
+    # two are most commonly wrong.
+    grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4)),
+                 'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8)),
+    }
+
+    for match in matches:
+        prefix, rest = match.split(':', maxsplit=1)
+        gr = grammars.get(prefix)
+        if gr:
+            try:
+                gr.parseString(rest)
+            except ParseBaseException as e:
+                error('Pattern {!r} is invalid: {}', rest, e)
+                continue
+            if rest[-1] not in '*:':
+                error('pattern {} does not end with "*" or ":"', match)
+
     matches.sort()
     prev = None
     for match in matches:
@@ -256,7 +278,7 @@ if __name__ == '__main__':
     for fname in args:
         groups = parse(fname)
         print_summary(fname, groups)
-        check_match_uniqueness(groups)
+        check_matches(groups)
         check_properties(groups)
 
     sys.exit(ERROR)
index 0345936fce0a2cbce2ed69a639f7432ab85cb174..ea93efd3f0153f6147455435f94e521ed8bf28cc 100644 (file)
@@ -3,7 +3,7 @@
   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
 
-<refentry id="systemd-initctl.service">
+<refentry id="systemd-initctl.service" conditional='HAVE_SYSV_COMPAT'>
 
   <refentryinfo>
     <title>systemd-initctl.service</title>
index 0c012b69fe1f81ac15fa1058be8378eba809f308..020a7e55ce8f8be16806978a410a50d153760219 100644 (file)
@@ -3080,7 +3080,7 @@ executable(
         link_with : [libshared],
         dependencies : [libaudit],
         install_rpath : rootlibexecdir,
-        install : true,
+        install : (conf.get('ENABLE_UTMP') == 1),
         install_dir : rootlibexecdir)
 
 if conf.get('HAVE_KMOD') == 1
index 8e86d2f0d1c01fbd89e3a21b97cebb4c0834de54..59ae6c7ad44ee3449235f6cecc08eaa9385e9d9d 100644 (file)
@@ -47,7 +47,7 @@ int udev_builtin_hwdb_lookup(sd_device *dev,
 }
 
 static const char *modalias_usb(sd_device *dev, char *s, size_t size) {
-        const char *v, *p;
+        const char *v, *p, *n = NULL;
         uint16_t vn, pn;
 
         if (sd_device_get_sysattr_value(dev, "idVendor", &v) < 0)
@@ -58,15 +58,16 @@ static const char *modalias_usb(sd_device *dev, char *s, size_t size) {
                 return NULL;
         if (safe_atoux16(p, &pn) < 0)
                 return NULL;
-        snprintf(s, size, "usb:v%04Xp%04X*", vn, pn);
+        (void) sd_device_get_sysattr_value(dev, "product", &n);
+
+        snprintf(s, size, "usb:v%04Xp%04X:%s", vn, pn, strempty(n));
         return s;
 }
 
 static int udev_builtin_hwdb_search(sd_device *dev, sd_device *srcdev,
                                     const char *subsystem, const char *prefix,
                                     const char *filter, bool test) {
-        sd_device *d;
-        char s[16];
+        char s[LINE_MAX];
         bool last = false;
         int r = 0;
 
@@ -75,7 +76,7 @@ static int udev_builtin_hwdb_search(sd_device *dev, sd_device *srcdev,
         if (!srcdev)
                 srcdev = dev;
 
-        for (d = srcdev; d; ) {
+        for (sd_device *d = srcdev; d; ) {
                 const char *dsubsys, *devtype, *modalias = NULL;
 
                 if (sd_device_get_subsystem(d, &dsubsys) < 0)
@@ -101,6 +102,8 @@ static int udev_builtin_hwdb_search(sd_device *dev, sd_device *srcdev,
                 if (!modalias)
                         goto next;
 
+                log_device_debug(dev, "hwdb modalias key: \"%s\"", modalias);
+
                 r = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test);
                 if (r > 0)
                         break;
index e13ca33f6fc5fcb2cff17aa6d872085717b8c387..a20edc0f341d673534c828d03f732f4b2dff5469 100755 (executable)
@@ -14,7 +14,7 @@ for entry in chromiumos.gen_autosuspend_rules.PCI_IDS:
     device = int(device, 16)
     print('pci:v{:08X}d{:08X}*'.format(vendor, device))
 
-print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice')
+print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice)')
 for entry in chromiumos.gen_autosuspend_rules.USB_IDS:
     vendor, product = entry.split(':')
     vendor = int(vendor, 16)
index c641900c668433a075f5e1899e73949301cf2373..aa2ed115ea2bcff8a146c4a10800547a76494482 100644 (file)
@@ -180,7 +180,7 @@ in_units = [
          'sysinit.target.wants/'],
         ['systemd-importd.service',              'ENABLE_IMPORTD',
          'dbus-org.freedesktop.import1.service'],
-        ['systemd-initctl.service',               ''],
+        ['systemd-initctl.service',              'HAVE_SYSV_COMPAT'],
         ['systemd-journal-gatewayd.service',     'ENABLE_REMOTE HAVE_MICROHTTPD'],
         ['systemd-journal-remote.service',       'ENABLE_REMOTE HAVE_MICROHTTPD'],
         ['systemd-journal-upload.service',       'ENABLE_REMOTE HAVE_LIBCURL'],