From 2ebe44c56750e7be5de2494bba1223d8e970df4f Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 17 Apr 2018 10:41:47 +0200 Subject: [PATCH 01/16] service: Reimplement per-profile configuration using snippets This commit removes file manipulation from %post, making it possible to install/remove package without side effects. Change-Id: I45103c134a7bb55da435146ff123a686e5cf4e56 --- packaging/emulator.conf | 3 +++ packaging/oom-adj-1000.conf | 2 ++ packaging/reset-privs.conf | 4 +++ packaging/restart-on-fail.conf | 3 +++ packaging/sdbd-env-generator | 3 +++ packaging/sdbd.service | 3 ++- packaging/sdbd.spec | 55 +++++++++++++++----------------------- packaging/sdbd@.socket | 6 ----- packaging/sdbd_device.service | 24 ----------------- packaging/sdbd_device_tv.service | 23 ---------------- packaging/sdbd_emulator.service | 25 ----------------- packaging/sdbd_emulator_tv.service | 23 ---------------- 12 files changed, 39 insertions(+), 135 deletions(-) create mode 100644 packaging/emulator.conf create mode 100644 packaging/oom-adj-1000.conf create mode 100644 packaging/reset-privs.conf create mode 100644 packaging/restart-on-fail.conf create mode 100755 packaging/sdbd-env-generator delete mode 100644 packaging/sdbd@.socket delete mode 100644 packaging/sdbd_device.service delete mode 100644 packaging/sdbd_device_tv.service delete mode 100644 packaging/sdbd_emulator.service delete mode 100644 packaging/sdbd_emulator_tv.service diff --git a/packaging/emulator.conf b/packaging/emulator.conf new file mode 100644 index 0000000..c2f6bc0 --- /dev/null +++ b/packaging/emulator.conf @@ -0,0 +1,3 @@ +[Unit] +After=dbus.service +Before=sensord.service diff --git a/packaging/oom-adj-1000.conf b/packaging/oom-adj-1000.conf new file mode 100644 index 0000000..bac841b --- /dev/null +++ b/packaging/oom-adj-1000.conf @@ -0,0 +1,2 @@ +[Service] +OOMScoreAdjust=-1000 diff --git a/packaging/reset-privs.conf b/packaging/reset-privs.conf new file mode 100644 index 0000000..c1af7ed --- /dev/null +++ b/packaging/reset-privs.conf @@ -0,0 +1,4 @@ +[Service] +User= +Group= +SmackProcessLabel= diff --git a/packaging/restart-on-fail.conf b/packaging/restart-on-fail.conf new file mode 100644 index 0000000..0e97dcb --- /dev/null +++ b/packaging/restart-on-fail.conf @@ -0,0 +1,3 @@ +[Service] +RemainAfterExit=no +Restart=on-failure diff --git a/packaging/sdbd-env-generator b/packaging/sdbd-env-generator new file mode 100755 index 0000000..c7f7aa6 --- /dev/null +++ b/packaging/sdbd-env-generator @@ -0,0 +1,3 @@ +#!/bin/sh + +awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print "SDBD_CMDLINE=\"--emulator=" vm_match[1] ":" port_match[1] " --connect-to=10.0.2.2:26099" " --sensors=10.0.2.2:"port_match[1]+3"\"" }' /proc/cmdline > /run/sdbd-env diff --git a/packaging/sdbd.service b/packaging/sdbd.service index 3ec4efc..e9b1047 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -6,6 +6,7 @@ After=tmp.mount User=sdk Group=sdk SmackProcessLabel=System +EnvironmentFile=-/run/sdbd-env #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" Type=simple @@ -13,6 +14,6 @@ Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i SecureBits=keep-caps PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes -ExecStart=/usr/sbin/sdbd +ExecStart=/usr/sbin/sdbd $SDBD_CMDLINE USBFunctionDescriptors=/etc/sdbd/descs USBFunctionStrings=/etc/sdbd/strs diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index a114dd8..baa5f86 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -8,13 +8,15 @@ License: Apache-2.0 Summary: SDB daemon Group: System/Utilities Source0: %{name}-%{version}.tar.gz -Source1001: sdbd_device.service -Source1002: sdbd_emulator.service -Source1003: %{name}.manifest +Source10: %{name}.manifest +Source1000: sdbd.service Source1004: sdbd_tcp.socket -Source1005: sdbd_device_tv.service -Source1006: sdbd_emulator_tv.service Source1007: sdbd.socket +Source1010: reset-privs.conf +Source1011: oom-adj-1000.conf +Source1012: emulator.conf +Source1013: restart-on-fail.conf +Source1020: sdbd-env-generator BuildRequires: capi-system-info-devel >= 0.2.0 BuildRequires: cmake >= 2.8.3 @@ -55,6 +57,7 @@ SDB daemon for emulator %package extension-tv-emulator Summary: SDB daemon for tv emulator Requires: %{name}-profile_tv = %{version}-%{release} +Requires: %{name}-extension-emulator = %{version}-%{release} %description extension-tv-emulator SDB daemon for tv emulator %endif // ifarch %{ix86} x86_64 @@ -68,7 +71,7 @@ SDBD plugin API library %prep %setup -q -cp %{SOURCE1003} . +cp %{SOURCE10} . %build cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?asan:-DCMAKE_EXE_LINKER_FLAGS="-pthread"} @@ -76,22 +79,24 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?asan:-DCMAKE_EXE_LINKER_FLAGS="-pth make %{?jobs:-j%jobs} %install -mkdir -p %{buildroot}%{_unitdir} +mkdir -p %{buildroot}%{_unitdir}/sdbd.service.d/ # extension-*-emulator %ifarch %{ix86} x86_64 -install -m 0644 %SOURCE1006 %{buildroot}%{_unitdir}/sdbd.service.tv.emulator -install -m 0644 %SOURCE1002 %{buildroot}%{_unitdir}/sdbd.service.emulator +install -m 0644 %SOURCE1010 %{buildroot}%{_unitdir}/sdbd.service.d/ +install -m 0644 %SOURCE1011 %{buildroot}%{_unitdir}/sdbd.service.d/ +install -m 0644 %SOURCE1012 %{buildroot}%{_unitdir}/sdbd.service.d/ +mkdir -p %{buildroot}%{_prefix}/lib/systemd/system-generators/ +install -m 0755 %SOURCE1020 %{buildroot}%{_prefix}/lib/systemd/system-generators/ mkdir -p %{buildroot}/%{_unitdir}/emulator_preinit.target.wants ln -s %{_unitdir}/sdbd.service %{buildroot}/%{_unitdir}/emulator_preinit.target.wants/ %endif // ifarch %{ix86} x86_64 %make_install -install -m 0644 %SOURCE1005 %{buildroot}%{_unitdir}/sdbd.service.tv -install -m 0644 %SOURCE1001 %{buildroot}%{_unitdir}/sdbd.service +install -m 0644 %SOURCE1000 %{buildroot}%{_unitdir}/sdbd.service install -m 0644 %SOURCE1004 %{buildroot}%{_unitdir}/sdbd_tcp.socket - +install -m 0644 %SOURCE1013 %{buildroot}%{_unitdir}/sdbd.service.d/restart-on-fail.conf install -m 0755 -d %{buildroot}%{_unitdir}/sockets.target.wants/ ln -s ../sdbd_tcp.socket %{buildroot}%{_unitdir}/sockets.target.wants/ @@ -143,36 +148,20 @@ chsmack -e "User::Shell" /sbin/sdbd-user %{_sysconfdir}/sdbd/strs %ifarch %{ix86} x86_64 -%post extension-emulator -mv %{_unitdir}/sdbd.service.emulator %{_unitdir}/sdbd.service -%preun extension-emulator -mv %{_unitdir}/sdbd.service %{_unitdir}/sdbd.service.emulator %files extension-emulator %manifest sdbd.manifest -%{_unitdir}/sdbd.service.emulator +%{_unitdir}/sdbd.service.d/emulator.conf %{_unitdir}/emulator_preinit.target.wants/sdbd.service +%{_prefix}/lib/systemd/system-generators/sdbd-env-generator -%post extension-tv-emulator -mv %{_unitdir}/sdbd.service.tv.emulator %{_unitdir}/sdbd.service -%preun extension-tv-emulator -mv %{_unitdir}/sdbd.service %{_unitdir}/sdbd.service.tv.emulator %files extension-tv-emulator %manifest sdbd.manifest -%{_unitdir}/sdbd.service.tv.emulator -%{_unitdir}/emulator_preinit.target.wants/sdbd.service +%{_unitdir}/sdbd.service.d/reset-privs.conf +%{_unitdir}/sdbd.service.d/oom-adj-1000.conf %endif // ifarch %{ix86} x86_64 -%post profile_tv -pushd %{_unitdir} -mv sdbd.service.tv sdbd.service -popd -%preun profile_tv -pushd %{_unitdir} -cp sdbd.service sdbd.service.tv -echo For correct bahavior of %{name} after uninstalling %{name}-profile_tv, you need to reinstall %{name} -popd %files profile_tv -%{_unitdir}/sdbd.service.tv +%{_unitdir}/sdbd.service.d/restart-on-fail.conf %files -n sdbd-devel %{_includedir}/sdb/sdbd_plugin.h diff --git a/packaging/sdbd@.socket b/packaging/sdbd@.socket deleted file mode 100644 index d53479e..0000000 --- a/packaging/sdbd@.socket +++ /dev/null @@ -1,6 +0,0 @@ -[Unit] -Description=sdbd Socket for %I - -[Socket] -ListenUSBFunction=%I -Service=sdbd.service diff --git a/packaging/sdbd_device.service b/packaging/sdbd_device.service deleted file mode 100644 index 080e0ed..0000000 --- a/packaging/sdbd_device.service +++ /dev/null @@ -1,24 +0,0 @@ -[Unit] -Description=sdbd -Requires=tizen-system-env.service -After=tmp.mount - -[Service] -User=sdk -Group=sdk -Type=simple -#location of SDBD log file -#If necessary, Put Environment variable settings in a file like below -#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" -EnvironmentFile=-/run/tizen-system-env -PIDFile=/tmp/.sdbd.pid -Restart=on-failure -SmackProcessLabel=System -Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i -SecureBits=keep-caps -ExecStart=/usr/sbin/sdbd -USBFunctionDescriptors=/etc/sdbd/descs -USBFunctionStrings=/etc/sdbd/strs - -[Install] -WantedBy=multi-user.target diff --git a/packaging/sdbd_device_tv.service b/packaging/sdbd_device_tv.service deleted file mode 100644 index 88d3a08..0000000 --- a/packaging/sdbd_device_tv.service +++ /dev/null @@ -1,23 +0,0 @@ -[Unit] -Description=sdbd -Requires=tizen-system-env.service -After=tmp.mount - -[Service] -Type=simple -#location of SDBD log file -#Environment=SDBD_LOG_PATH=/tmp -#If necessary, Put Environment variable settings in a file like below -#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" -EnvironmentFile=-/run/tizen-system-env -OOMScoreAdjust=-1000 -PIDFile=/tmp/.sdbd.pid -Restart=on-failure -Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i -SecureBits=keep-caps -ExecStart=/usr/sbin/sdbd -USBFunctionDescriptors=/etc/sdbd/descs -USBFunctionStrings=/etc/sdbd/strs - -[Install] -WantedBy=multi-user.target diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service deleted file mode 100644 index 5ace52d..0000000 --- a/packaging/sdbd_emulator.service +++ /dev/null @@ -1,25 +0,0 @@ -[Unit] -Description=sdbd -Before=sensord.service -After=tmp.mount dbus.service -#DefaultDependencies=false - -[Service] -User=sdk -Group=sdk -Type=simple -PIDFile=/tmp/.sdbd.pid -RemainAfterExit=yes -#If necessary, Put Environment variable settings in a file like below -#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" -#ExecStartPre=/bin/bash -c "/bin/echo '10.0.2.15/32 system::debugging_network' >> /smack/netlabel" -SmackProcessLabel=System -Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i -SecureBits=keep-caps -ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`" -USBFunctionDescriptors=/etc/sdbd/descs -USBFunctionStrings=/etc/sdbd/strs - -[Install] -WantedBy=emulator_preinit.target - diff --git a/packaging/sdbd_emulator_tv.service b/packaging/sdbd_emulator_tv.service deleted file mode 100644 index 8d45fea..0000000 --- a/packaging/sdbd_emulator_tv.service +++ /dev/null @@ -1,23 +0,0 @@ -[Unit] -Description=sdbd -Before=sensord.service -After=tmp.mount dbus.service -#DefaultDependencies=false - -[Service] -Type=simple -#location of SDBD log file -#Environment=SDBD_LOG_PATH=/tmp -#If necessary, Put Environment variable settings in a file like below -#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" -PIDFile=/tmp/.sdbd.pid -RemainAfterExit=yes -OOMScoreAdjust=-1000 -Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i -SecureBits=keep-caps -#ExecStartPre=/bin/bash -c "/bin/echo '10.0.2.15/32 system::debugging_network' >> /smack/netlabel" -ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`" - -[Install] -WantedBy=emulator_preinit.target - -- 2.7.4 From 5c0ef2844b81a5855f0828195c3d90f883d14dc6 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Wed, 18 Apr 2018 13:07:31 +0200 Subject: [PATCH 02/16] sdb: Use systemd startup notification Change-Id: I8ec201a68be921861f0fb05b74f1d862a4c90e5f Signed-off-by: Karol Lewandowski --- packaging/sdbd.service | 2 +- src/sdb.c | 4 +++- src/sdb_systemd.h | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packaging/sdbd.service b/packaging/sdbd.service index e9b1047..0086137 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -9,7 +9,7 @@ SmackProcessLabel=System EnvironmentFile=-/run/sdbd-env #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" -Type=simple +Type=notify Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i SecureBits=keep-caps PIDFile=/tmp/.sdbd.pid diff --git a/src/sdb.c b/src/sdb.c index fe77333..c014f34 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -42,6 +42,7 @@ #include "sdktools.h" #include "plugin.h" #include "sdbd_plugin.h" +#include "sdb_systemd.h" #ifdef SUPPORT_ENCRYPT #include "plugin_encrypt.h" @@ -2127,6 +2128,8 @@ int sdb_main(int server_port) D("sdb_main(): post init_jdwp()\n"); #endif + sdb_notify_startup(0, "READY=1"); + D("Event loop starting\n"); fdevent_loop(); @@ -2271,4 +2274,3 @@ int main(int argc, char **argv) signal(SIGTERM, handle_sig_term); /* tizen specific */ return sdb_main(DEFAULT_SDB_PORT); } - diff --git a/src/sdb_systemd.h b/src/sdb_systemd.h index f183389..f9aeb18 100644 --- a/src/sdb_systemd.h +++ b/src/sdb_systemd.h @@ -7,6 +7,10 @@ #include #include "sysdeps.h" +static __inline__ void sdb_notify_startup(int unset_env, const char *state) +{ + sd_notify(unset_env, state); +} static int sdb_port_get_tcp_listenfd(void) { @@ -31,6 +35,8 @@ static __inline__ int sdb_port_try_automatic(void) #else +static __inline__ void sdb_notify_startup(int unset_env, const char *state) { } + static __inline__ int sdb_port_get_tcp_listenfd(void) { return -1; -- 2.7.4 From 0b0721f4e65c7626045256473f43488edf67798b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Wed, 18 Apr 2018 15:09:51 +0200 Subject: [PATCH 03/16] usb_funcfs: Check descriptors received from systemd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I178e04a49f4691923455066572f1e26396c65af4 Signed-off-by: Paweł Szewczyk --- src/usb_funcfs_client.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/usb_funcfs_client.c b/src/usb_funcfs_client.c index 94f56f4..a7cee7d 100644 --- a/src/usb_funcfs_client.c +++ b/src/usb_funcfs_client.c @@ -138,13 +138,29 @@ error: static void *usb_open_thread(void *x) { struct usb_handle *usb = (struct usb_handle *)x; + int maxfd = sd_listen_fds(0) + SD_LISTEN_FDS_START; + int fd; + int ep[3]; + int received; + + usb->control = -1; + usb->bulk_in = -1; + usb->bulk_out = -1; + + received = 0; + for (fd = SD_LISTEN_FDS_START; fd < maxfd; ++fd) { + if (sd_is_special(fd, NULL) > 0) { + ep[received++] = fd; + } + } /* Endpoints are received from sytemd */ - if (sd_listen_fds(0) >= 3) { + if (received == 3) { + D("Using functionfs socket activation\n"); sdb_mutex_lock(&usb->control_lock); - usb->control = SD_LISTEN_FDS_START + 0; - usb->bulk_out = SD_LISTEN_FDS_START + 1; - usb->bulk_in = SD_LISTEN_FDS_START + 2; + usb->control = ep[0]; + usb->bulk_out = ep[1]; + usb->bulk_in = ep[2]; sdb_cond_signal(&usb->control_notify); sdb_mutex_unlock(&usb->control_lock); } else { -- 2.7.4 From 146a580de79a7e9ff75e9a525fb6c70be7f98f48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Thu, 26 Apr 2018 13:57:47 +0200 Subject: [PATCH 04/16] Remove usage of /run/tizen-system-env file MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This file is created by tizen-system-env.service, which is no longer a dependency. Change-Id: Ie1000550b106f407c338b607878c6e38577046b2 Signed-off-by: Paweł Szewczyk --- packaging/sdbd.service | 1 - 1 file changed, 1 deletion(-) diff --git a/packaging/sdbd.service b/packaging/sdbd.service index 0086137..ce43bfd 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -6,7 +6,6 @@ After=tmp.mount User=sdk Group=sdk SmackProcessLabel=System -EnvironmentFile=-/run/sdbd-env #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" Type=notify -- 2.7.4 From 1376e40eaf97bd9c5586d5ef77e4bbb9e0683c3f Mon Sep 17 00:00:00 2001 From: Manish Rathod Date: Fri, 4 May 2018 10:07:42 +0000 Subject: [PATCH 05/16] Revert "Remove usage of /run/tizen-system-env file" This reverts commit 146a580de79a7e9ff75e9a525fb6c70be7f98f48. Change-Id: I59ea36a928dd7d780d9be48c9d2fba61402dbd83 --- packaging/sdbd.service | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/sdbd.service b/packaging/sdbd.service index ce43bfd..0086137 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -6,6 +6,7 @@ After=tmp.mount User=sdk Group=sdk SmackProcessLabel=System +EnvironmentFile=-/run/sdbd-env #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" Type=notify -- 2.7.4 From 54f43e108db2665341d553573f002f296e012987 Mon Sep 17 00:00:00 2001 From: Manish Rathod Date: Fri, 4 May 2018 10:09:57 +0000 Subject: [PATCH 06/16] Revert "usb_funcfs: Check descriptors received from systemd" This reverts commit 0b0721f4e65c7626045256473f43488edf67798b. Change-Id: Ib532b431a8ab4fe847121ac362c595fb6b20fcbc --- src/usb_funcfs_client.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/usb_funcfs_client.c b/src/usb_funcfs_client.c index a7cee7d..94f56f4 100644 --- a/src/usb_funcfs_client.c +++ b/src/usb_funcfs_client.c @@ -138,29 +138,13 @@ error: static void *usb_open_thread(void *x) { struct usb_handle *usb = (struct usb_handle *)x; - int maxfd = sd_listen_fds(0) + SD_LISTEN_FDS_START; - int fd; - int ep[3]; - int received; - - usb->control = -1; - usb->bulk_in = -1; - usb->bulk_out = -1; - - received = 0; - for (fd = SD_LISTEN_FDS_START; fd < maxfd; ++fd) { - if (sd_is_special(fd, NULL) > 0) { - ep[received++] = fd; - } - } /* Endpoints are received from sytemd */ - if (received == 3) { - D("Using functionfs socket activation\n"); + if (sd_listen_fds(0) >= 3) { sdb_mutex_lock(&usb->control_lock); - usb->control = ep[0]; - usb->bulk_out = ep[1]; - usb->bulk_in = ep[2]; + usb->control = SD_LISTEN_FDS_START + 0; + usb->bulk_out = SD_LISTEN_FDS_START + 1; + usb->bulk_in = SD_LISTEN_FDS_START + 2; sdb_cond_signal(&usb->control_notify); sdb_mutex_unlock(&usb->control_lock); } else { -- 2.7.4 From 95ba741bb4fc70acf13d4ef68d3a15031025aa6f Mon Sep 17 00:00:00 2001 From: Manish Rathod Date: Fri, 4 May 2018 10:10:23 +0000 Subject: [PATCH 07/16] Revert "sdb: Use systemd startup notification" This reverts commit 5c0ef2844b81a5855f0828195c3d90f883d14dc6. Change-Id: I9cf43c66bcd3bfbe1d50c9df14f8de4a67e55a0a --- packaging/sdbd.service | 2 +- src/sdb.c | 4 +--- src/sdb_systemd.h | 6 ------ 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packaging/sdbd.service b/packaging/sdbd.service index 0086137..e9b1047 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -9,7 +9,7 @@ SmackProcessLabel=System EnvironmentFile=-/run/sdbd-env #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" -Type=notify +Type=simple Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i SecureBits=keep-caps PIDFile=/tmp/.sdbd.pid diff --git a/src/sdb.c b/src/sdb.c index c014f34..fe77333 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -42,7 +42,6 @@ #include "sdktools.h" #include "plugin.h" #include "sdbd_plugin.h" -#include "sdb_systemd.h" #ifdef SUPPORT_ENCRYPT #include "plugin_encrypt.h" @@ -2128,8 +2127,6 @@ int sdb_main(int server_port) D("sdb_main(): post init_jdwp()\n"); #endif - sdb_notify_startup(0, "READY=1"); - D("Event loop starting\n"); fdevent_loop(); @@ -2274,3 +2271,4 @@ int main(int argc, char **argv) signal(SIGTERM, handle_sig_term); /* tizen specific */ return sdb_main(DEFAULT_SDB_PORT); } + diff --git a/src/sdb_systemd.h b/src/sdb_systemd.h index f9aeb18..f183389 100644 --- a/src/sdb_systemd.h +++ b/src/sdb_systemd.h @@ -7,10 +7,6 @@ #include #include "sysdeps.h" -static __inline__ void sdb_notify_startup(int unset_env, const char *state) -{ - sd_notify(unset_env, state); -} static int sdb_port_get_tcp_listenfd(void) { @@ -35,8 +31,6 @@ static __inline__ int sdb_port_try_automatic(void) #else -static __inline__ void sdb_notify_startup(int unset_env, const char *state) { } - static __inline__ int sdb_port_get_tcp_listenfd(void) { return -1; -- 2.7.4 From 5aa4d053853caf9d74eba1bbcdb6c7dcfef10b32 Mon Sep 17 00:00:00 2001 From: Manish Rathod Date: Fri, 4 May 2018 10:25:35 +0000 Subject: [PATCH 08/16] Revert "service: Reimplement per-profile configuration using snippets" This reverts commit 2ebe44c56750e7be5de2494bba1223d8e970df4f. Change-Id: I82d9da6d12e9e4f1e6900963a1de09ddd213a3c4 --- packaging/emulator.conf | 3 --- packaging/oom-adj-1000.conf | 2 -- packaging/reset-privs.conf | 4 --- packaging/restart-on-fail.conf | 3 --- packaging/sdbd-env-generator | 3 --- packaging/sdbd.service | 3 +-- packaging/sdbd.spec | 55 +++++++++++++++++++++++--------------- packaging/sdbd@.socket | 6 +++++ packaging/sdbd_device.service | 24 +++++++++++++++++ packaging/sdbd_device_tv.service | 23 ++++++++++++++++ packaging/sdbd_emulator.service | 25 +++++++++++++++++ packaging/sdbd_emulator_tv.service | 23 ++++++++++++++++ 12 files changed, 135 insertions(+), 39 deletions(-) delete mode 100644 packaging/emulator.conf delete mode 100644 packaging/oom-adj-1000.conf delete mode 100644 packaging/reset-privs.conf delete mode 100644 packaging/restart-on-fail.conf delete mode 100755 packaging/sdbd-env-generator create mode 100644 packaging/sdbd@.socket create mode 100644 packaging/sdbd_device.service create mode 100644 packaging/sdbd_device_tv.service create mode 100644 packaging/sdbd_emulator.service create mode 100644 packaging/sdbd_emulator_tv.service diff --git a/packaging/emulator.conf b/packaging/emulator.conf deleted file mode 100644 index c2f6bc0..0000000 --- a/packaging/emulator.conf +++ /dev/null @@ -1,3 +0,0 @@ -[Unit] -After=dbus.service -Before=sensord.service diff --git a/packaging/oom-adj-1000.conf b/packaging/oom-adj-1000.conf deleted file mode 100644 index bac841b..0000000 --- a/packaging/oom-adj-1000.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Service] -OOMScoreAdjust=-1000 diff --git a/packaging/reset-privs.conf b/packaging/reset-privs.conf deleted file mode 100644 index c1af7ed..0000000 --- a/packaging/reset-privs.conf +++ /dev/null @@ -1,4 +0,0 @@ -[Service] -User= -Group= -SmackProcessLabel= diff --git a/packaging/restart-on-fail.conf b/packaging/restart-on-fail.conf deleted file mode 100644 index 0e97dcb..0000000 --- a/packaging/restart-on-fail.conf +++ /dev/null @@ -1,3 +0,0 @@ -[Service] -RemainAfterExit=no -Restart=on-failure diff --git a/packaging/sdbd-env-generator b/packaging/sdbd-env-generator deleted file mode 100755 index c7f7aa6..0000000 --- a/packaging/sdbd-env-generator +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print "SDBD_CMDLINE=\"--emulator=" vm_match[1] ":" port_match[1] " --connect-to=10.0.2.2:26099" " --sensors=10.0.2.2:"port_match[1]+3"\"" }' /proc/cmdline > /run/sdbd-env diff --git a/packaging/sdbd.service b/packaging/sdbd.service index e9b1047..3ec4efc 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -6,7 +6,6 @@ After=tmp.mount User=sdk Group=sdk SmackProcessLabel=System -EnvironmentFile=-/run/sdbd-env #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" Type=simple @@ -14,6 +13,6 @@ Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i SecureBits=keep-caps PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes -ExecStart=/usr/sbin/sdbd $SDBD_CMDLINE +ExecStart=/usr/sbin/sdbd USBFunctionDescriptors=/etc/sdbd/descs USBFunctionStrings=/etc/sdbd/strs diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index baa5f86..a114dd8 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -8,15 +8,13 @@ License: Apache-2.0 Summary: SDB daemon Group: System/Utilities Source0: %{name}-%{version}.tar.gz -Source10: %{name}.manifest -Source1000: sdbd.service +Source1001: sdbd_device.service +Source1002: sdbd_emulator.service +Source1003: %{name}.manifest Source1004: sdbd_tcp.socket +Source1005: sdbd_device_tv.service +Source1006: sdbd_emulator_tv.service Source1007: sdbd.socket -Source1010: reset-privs.conf -Source1011: oom-adj-1000.conf -Source1012: emulator.conf -Source1013: restart-on-fail.conf -Source1020: sdbd-env-generator BuildRequires: capi-system-info-devel >= 0.2.0 BuildRequires: cmake >= 2.8.3 @@ -57,7 +55,6 @@ SDB daemon for emulator %package extension-tv-emulator Summary: SDB daemon for tv emulator Requires: %{name}-profile_tv = %{version}-%{release} -Requires: %{name}-extension-emulator = %{version}-%{release} %description extension-tv-emulator SDB daemon for tv emulator %endif // ifarch %{ix86} x86_64 @@ -71,7 +68,7 @@ SDBD plugin API library %prep %setup -q -cp %{SOURCE10} . +cp %{SOURCE1003} . %build cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?asan:-DCMAKE_EXE_LINKER_FLAGS="-pthread"} @@ -79,24 +76,22 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?asan:-DCMAKE_EXE_LINKER_FLAGS="-pth make %{?jobs:-j%jobs} %install -mkdir -p %{buildroot}%{_unitdir}/sdbd.service.d/ +mkdir -p %{buildroot}%{_unitdir} # extension-*-emulator %ifarch %{ix86} x86_64 -install -m 0644 %SOURCE1010 %{buildroot}%{_unitdir}/sdbd.service.d/ -install -m 0644 %SOURCE1011 %{buildroot}%{_unitdir}/sdbd.service.d/ -install -m 0644 %SOURCE1012 %{buildroot}%{_unitdir}/sdbd.service.d/ -mkdir -p %{buildroot}%{_prefix}/lib/systemd/system-generators/ -install -m 0755 %SOURCE1020 %{buildroot}%{_prefix}/lib/systemd/system-generators/ +install -m 0644 %SOURCE1006 %{buildroot}%{_unitdir}/sdbd.service.tv.emulator +install -m 0644 %SOURCE1002 %{buildroot}%{_unitdir}/sdbd.service.emulator mkdir -p %{buildroot}/%{_unitdir}/emulator_preinit.target.wants ln -s %{_unitdir}/sdbd.service %{buildroot}/%{_unitdir}/emulator_preinit.target.wants/ %endif // ifarch %{ix86} x86_64 %make_install -install -m 0644 %SOURCE1000 %{buildroot}%{_unitdir}/sdbd.service +install -m 0644 %SOURCE1005 %{buildroot}%{_unitdir}/sdbd.service.tv +install -m 0644 %SOURCE1001 %{buildroot}%{_unitdir}/sdbd.service install -m 0644 %SOURCE1004 %{buildroot}%{_unitdir}/sdbd_tcp.socket -install -m 0644 %SOURCE1013 %{buildroot}%{_unitdir}/sdbd.service.d/restart-on-fail.conf + install -m 0755 -d %{buildroot}%{_unitdir}/sockets.target.wants/ ln -s ../sdbd_tcp.socket %{buildroot}%{_unitdir}/sockets.target.wants/ @@ -148,20 +143,36 @@ chsmack -e "User::Shell" /sbin/sdbd-user %{_sysconfdir}/sdbd/strs %ifarch %{ix86} x86_64 +%post extension-emulator +mv %{_unitdir}/sdbd.service.emulator %{_unitdir}/sdbd.service +%preun extension-emulator +mv %{_unitdir}/sdbd.service %{_unitdir}/sdbd.service.emulator %files extension-emulator %manifest sdbd.manifest -%{_unitdir}/sdbd.service.d/emulator.conf +%{_unitdir}/sdbd.service.emulator %{_unitdir}/emulator_preinit.target.wants/sdbd.service -%{_prefix}/lib/systemd/system-generators/sdbd-env-generator +%post extension-tv-emulator +mv %{_unitdir}/sdbd.service.tv.emulator %{_unitdir}/sdbd.service +%preun extension-tv-emulator +mv %{_unitdir}/sdbd.service %{_unitdir}/sdbd.service.tv.emulator %files extension-tv-emulator %manifest sdbd.manifest -%{_unitdir}/sdbd.service.d/reset-privs.conf -%{_unitdir}/sdbd.service.d/oom-adj-1000.conf +%{_unitdir}/sdbd.service.tv.emulator +%{_unitdir}/emulator_preinit.target.wants/sdbd.service %endif // ifarch %{ix86} x86_64 +%post profile_tv +pushd %{_unitdir} +mv sdbd.service.tv sdbd.service +popd +%preun profile_tv +pushd %{_unitdir} +cp sdbd.service sdbd.service.tv +echo For correct bahavior of %{name} after uninstalling %{name}-profile_tv, you need to reinstall %{name} +popd %files profile_tv -%{_unitdir}/sdbd.service.d/restart-on-fail.conf +%{_unitdir}/sdbd.service.tv %files -n sdbd-devel %{_includedir}/sdb/sdbd_plugin.h diff --git a/packaging/sdbd@.socket b/packaging/sdbd@.socket new file mode 100644 index 0000000..d53479e --- /dev/null +++ b/packaging/sdbd@.socket @@ -0,0 +1,6 @@ +[Unit] +Description=sdbd Socket for %I + +[Socket] +ListenUSBFunction=%I +Service=sdbd.service diff --git a/packaging/sdbd_device.service b/packaging/sdbd_device.service new file mode 100644 index 0000000..080e0ed --- /dev/null +++ b/packaging/sdbd_device.service @@ -0,0 +1,24 @@ +[Unit] +Description=sdbd +Requires=tizen-system-env.service +After=tmp.mount + +[Service] +User=sdk +Group=sdk +Type=simple +#location of SDBD log file +#If necessary, Put Environment variable settings in a file like below +#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" +EnvironmentFile=-/run/tizen-system-env +PIDFile=/tmp/.sdbd.pid +Restart=on-failure +SmackProcessLabel=System +Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i +SecureBits=keep-caps +ExecStart=/usr/sbin/sdbd +USBFunctionDescriptors=/etc/sdbd/descs +USBFunctionStrings=/etc/sdbd/strs + +[Install] +WantedBy=multi-user.target diff --git a/packaging/sdbd_device_tv.service b/packaging/sdbd_device_tv.service new file mode 100644 index 0000000..88d3a08 --- /dev/null +++ b/packaging/sdbd_device_tv.service @@ -0,0 +1,23 @@ +[Unit] +Description=sdbd +Requires=tizen-system-env.service +After=tmp.mount + +[Service] +Type=simple +#location of SDBD log file +#Environment=SDBD_LOG_PATH=/tmp +#If necessary, Put Environment variable settings in a file like below +#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" +EnvironmentFile=-/run/tizen-system-env +OOMScoreAdjust=-1000 +PIDFile=/tmp/.sdbd.pid +Restart=on-failure +Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i +SecureBits=keep-caps +ExecStart=/usr/sbin/sdbd +USBFunctionDescriptors=/etc/sdbd/descs +USBFunctionStrings=/etc/sdbd/strs + +[Install] +WantedBy=multi-user.target diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service new file mode 100644 index 0000000..5ace52d --- /dev/null +++ b/packaging/sdbd_emulator.service @@ -0,0 +1,25 @@ +[Unit] +Description=sdbd +Before=sensord.service +After=tmp.mount dbus.service +#DefaultDependencies=false + +[Service] +User=sdk +Group=sdk +Type=simple +PIDFile=/tmp/.sdbd.pid +RemainAfterExit=yes +#If necessary, Put Environment variable settings in a file like below +#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" +#ExecStartPre=/bin/bash -c "/bin/echo '10.0.2.15/32 system::debugging_network' >> /smack/netlabel" +SmackProcessLabel=System +Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i +SecureBits=keep-caps +ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`" +USBFunctionDescriptors=/etc/sdbd/descs +USBFunctionStrings=/etc/sdbd/strs + +[Install] +WantedBy=emulator_preinit.target + diff --git a/packaging/sdbd_emulator_tv.service b/packaging/sdbd_emulator_tv.service new file mode 100644 index 0000000..8d45fea --- /dev/null +++ b/packaging/sdbd_emulator_tv.service @@ -0,0 +1,23 @@ +[Unit] +Description=sdbd +Before=sensord.service +After=tmp.mount dbus.service +#DefaultDependencies=false + +[Service] +Type=simple +#location of SDBD log file +#Environment=SDBD_LOG_PATH=/tmp +#If necessary, Put Environment variable settings in a file like below +#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" +PIDFile=/tmp/.sdbd.pid +RemainAfterExit=yes +OOMScoreAdjust=-1000 +Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i +SecureBits=keep-caps +#ExecStartPre=/bin/bash -c "/bin/echo '10.0.2.15/32 system::debugging_network' >> /smack/netlabel" +ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`" + +[Install] +WantedBy=emulator_preinit.target + -- 2.7.4 From 4e194560ee8b9b4d099021ac98c6369334b729af Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:28:23 +0000 Subject: [PATCH 09/16] Revert "Enable systemd activation for TCP ports" This reverts commit 8c8b42c7a78a0604172001e2ce430cab1f95cba7. Change-Id: I62b5f16f2dfb095a984071ffefceadc08be11c31 --- packaging/sdbd.spec | 11 +++-------- packaging/sdbd_tcp.service | 16 ++++++++++++++++ packaging/sdbd_tcp.socket | 11 ----------- src/commandline_sdbd.c | 7 ++----- src/sdb_systemd.h | 45 --------------------------------------------- src/transport_local.c | 4 +--- 6 files changed, 22 insertions(+), 72 deletions(-) create mode 100644 packaging/sdbd_tcp.service delete mode 100644 packaging/sdbd_tcp.socket delete mode 100644 src/sdb_systemd.h diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index a114dd8..57a4dbb 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -11,7 +11,7 @@ Source0: %{name}-%{version}.tar.gz Source1001: sdbd_device.service Source1002: sdbd_emulator.service Source1003: %{name}.manifest -Source1004: sdbd_tcp.socket +Source1004: sdbd_tcp.service Source1005: sdbd_device_tv.service Source1006: sdbd_emulator_tv.service Source1007: sdbd.socket @@ -28,7 +28,6 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(libsystemd) Requires: dbus Provides: %{name}-profile_common = %{version}-%{release} Provides: %{name}-profile_mobile = %{version}-%{release} @@ -90,10 +89,7 @@ ln -s %{_unitdir}/sdbd.service %{buildroot}/%{_unitdir}/emulator_preinit.target. install -m 0644 %SOURCE1005 %{buildroot}%{_unitdir}/sdbd.service.tv install -m 0644 %SOURCE1001 %{buildroot}%{_unitdir}/sdbd.service -install -m 0644 %SOURCE1004 %{buildroot}%{_unitdir}/sdbd_tcp.socket - -install -m 0755 -d %{buildroot}%{_unitdir}/sockets.target.wants/ -ln -s ../sdbd_tcp.socket %{buildroot}%{_unitdir}/sockets.target.wants/ +install -m 0644 %SOURCE1004 %{buildroot}%{_unitdir}/sdbd_tcp.service mkdir -p %{buildroot}%{_prefix}/lib/udev/rules.d/ install -m 644 rules/99-sdbd.rules %{buildroot}%{_prefix}/lib/udev/rules.d/ @@ -135,8 +131,7 @@ chsmack -e "User::Shell" /sbin/sdbd-user %attr(0755, root, root) %{_sysconfdir}/init.d/sdbd %{_unitdir}/sdbd.service %{_unitdir}/sdbd.socket -%{_unitdir}/sdbd_tcp.socket -%{_unitdir}/sockets.target.wants/sdbd_tcp.socket +%{_unitdir}/sdbd_tcp.service %{_prefix}/lib/udev/rules.d/99-sdbd.rules %{TZ_SYS_BIN}/profile_command %{_sysconfdir}/sdbd/descs diff --git a/packaging/sdbd_tcp.service b/packaging/sdbd_tcp.service new file mode 100644 index 0000000..fd5ec24 --- /dev/null +++ b/packaging/sdbd_tcp.service @@ -0,0 +1,16 @@ +[Unit] +Description=sdbd +After=default.target + +[Service] +User=sdk +Group=sdk +Type=simple +#If necessary, Put Environment variable settings in a file like below +#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" +PIDFile=/tmp/.sdbd.pid +RemainAfterExit=yes +SmackProcessLabel=System +Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i +SecureBits=keep-caps +ExecStart=/usr/sbin/sdbd --listen-port=26101 diff --git a/packaging/sdbd_tcp.socket b/packaging/sdbd_tcp.socket deleted file mode 100644 index 0cfae9c..0000000 --- a/packaging/sdbd_tcp.socket +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=sdbd: TCP socket - -[Socket] -ListenStream=26101 -SmackLabelIPIn=* -SmackLabelIPOut=@ -Service=sdbd.service - -[Install] -WantedBy=sockets.target diff --git a/src/commandline_sdbd.c b/src/commandline_sdbd.c index bf57048..eee6ac2 100644 --- a/src/commandline_sdbd.c +++ b/src/commandline_sdbd.c @@ -16,7 +16,6 @@ #include "commandline_sdbd.h" #include "sdb.h" -#include "sdb_systemd.h" #include #include @@ -110,8 +109,6 @@ int parse_sdbd_commandline(SdbdCommandlineArgs *sdbd_args, int argc, char *argv[ if (sscanf(optarg, "%d", &sdbd_args->sdbd_port) < 1) { return SDBD_COMMANDLINE_FAILURE; } - if (sdb_port_get_tcp_listenfd() != -1) - printf("warning: sdb port was provided by systemd but overriden from command line\n"); print_sdbd_command(stdout, sdbd_args); break; case ARG_S_HELP: @@ -142,8 +139,8 @@ void apply_sdbd_commandline_defaults(SdbdCommandlineArgs *sdbd_args) { sdbd_args->sdb.host = strdup(QEMU_FORWARD_IP); sdbd_args->sdb.port = DEFAULT_SDB_PORT; - // by default don't listen on local transport (unless systemd passed it) - sdbd_args->sdbd_port = sdb_port_try_automatic(); + // by default don't listen on local transport + sdbd_args->sdbd_port = -1; } diff --git a/src/sdb_systemd.h b/src/sdb_systemd.h deleted file mode 100644 index f183389..0000000 --- a/src/sdb_systemd.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef SDB_SYSTEMD_H -#define SDB_SYSTEMD_H - -#ifndef _WIN32 - -#include -#include -#include "sysdeps.h" - - -static int sdb_port_get_tcp_listenfd(void) -{ - int fd = -1; - int maxfd = sd_listen_fds(0) + SD_LISTEN_FDS_START; - - for (fd = SD_LISTEN_FDS_START; fd < maxfd; fd++) { - if (sd_is_socket_inet(fd, AF_INET, SOCK_STREAM, 1, 0) > 0 - || sd_is_socket_inet(fd, AF_INET6, SOCK_STREAM, 1, 0) > 0) { - close_on_exec(fd); - return fd; - } - } - - return -1; -} - -static __inline__ int sdb_port_try_automatic(void) -{ - return sd_listen_fds(0) > 0 ? 0 : -1; -} - -#else - -static __inline__ int sdb_port_get_tcp_listenfd(void) -{ - return -1; -} - -static __inline__ int sdb_port_try_automatic(void) -{ - return -1; -} -#endif /* _WIN32 */ - -#endif /* SDB_SYSTEMD_H */ diff --git a/src/transport_local.c b/src/transport_local.c index ab307d5..58a07a4 100644 --- a/src/transport_local.c +++ b/src/transport_local.c @@ -22,8 +22,6 @@ #include #include "sysdeps.h" -#include "sdb_systemd.h" - #include #ifndef HAVE_WIN32_IPC @@ -151,7 +149,7 @@ static void *server_socket_thread(void * arg) int port = (intptr_t)arg; D("transport: server_socket_thread() starting\n"); - serverfd = sdb_port_get_tcp_listenfd(); + serverfd = -1; for(;;) { if(serverfd == -1) { // socket_inaddr_any_server returns -1 if there is any error -- 2.7.4 From d9aadf4e5bad0ae2584921bd7bddd321bcdc8b9e Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:29:20 +0000 Subject: [PATCH 10/16] Revert "service: Remove DISPLAY=:0 from all services" This reverts commit 1699dc9ae3c9bf2d8fae27b7611272ad2f2aa5f9. Change-Id: Ia4fbb68f0bbe844511225ae6e5c5790b3f4dab57 --- packaging/sdbd_emulator.service | 1 + packaging/sdbd_emulator_tv.service | 1 + packaging/sdbd_tcp.service | 1 + 3 files changed, 3 insertions(+) diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service index 5ace52d..9b87f40 100644 --- a/packaging/sdbd_emulator.service +++ b/packaging/sdbd_emulator.service @@ -8,6 +8,7 @@ After=tmp.mount dbus.service User=sdk Group=sdk Type=simple +Environment=DISPLAY=:0 PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes #If necessary, Put Environment variable settings in a file like below diff --git a/packaging/sdbd_emulator_tv.service b/packaging/sdbd_emulator_tv.service index 8d45fea..3dc42e3 100644 --- a/packaging/sdbd_emulator_tv.service +++ b/packaging/sdbd_emulator_tv.service @@ -10,6 +10,7 @@ Type=simple #Environment=SDBD_LOG_PATH=/tmp #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" +Environment=DISPLAY=:0 PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes OOMScoreAdjust=-1000 diff --git a/packaging/sdbd_tcp.service b/packaging/sdbd_tcp.service index fd5ec24..6871f29 100644 --- a/packaging/sdbd_tcp.service +++ b/packaging/sdbd_tcp.service @@ -6,6 +6,7 @@ After=default.target User=sdk Group=sdk Type=simple +Environment=DISPLAY=:0 #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" PIDFile=/tmp/.sdbd.pid -- 2.7.4 From 6ad6a2da4ee65dfaacd41f2742da2d5ed4d868c6 Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:30:00 +0000 Subject: [PATCH 11/16] Revert "service: Move common options to sdbd.service" This reverts commit 5d2df4af01380736a240b652472f217f9766aebb. Change-Id: Idabbc67cad254d9ae0bb615aaac0779177dd92fb --- packaging/sdbd.service | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packaging/sdbd.service b/packaging/sdbd.service index 3ec4efc..eb49efe 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -1,16 +1,10 @@ [Unit] Description=sdbd -After=tmp.mount [Service] -User=sdk -Group=sdk -SmackProcessLabel=System #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" Type=simple -Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i -SecureBits=keep-caps PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes ExecStart=/usr/sbin/sdbd -- 2.7.4 From 3025967f84b97489d32067daa3368dbfe69abce0 Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:32:52 +0000 Subject: [PATCH 12/16] Revert "Don't start sdbd on system boot" This reverts commit 691cc0ef8d5c9d4862c2f3c23719218c1e3f2b47. Change-Id: Id54c36775a4feee5750d3bd94a9021d7991d37d6 --- packaging/sdbd.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 57a4dbb..b026aef 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -90,6 +90,8 @@ ln -s %{_unitdir}/sdbd.service %{buildroot}/%{_unitdir}/emulator_preinit.target. install -m 0644 %SOURCE1005 %{buildroot}%{_unitdir}/sdbd.service.tv install -m 0644 %SOURCE1001 %{buildroot}%{_unitdir}/sdbd.service install -m 0644 %SOURCE1004 %{buildroot}%{_unitdir}/sdbd_tcp.service +mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants +ln -s %{_unitdir}/sdbd.service %{buildroot}/%{_unitdir}/multi-user.target.wants/ mkdir -p %{buildroot}%{_prefix}/lib/udev/rules.d/ install -m 644 rules/99-sdbd.rules %{buildroot}%{_prefix}/lib/udev/rules.d/ @@ -132,6 +134,7 @@ chsmack -e "User::Shell" /sbin/sdbd-user %{_unitdir}/sdbd.service %{_unitdir}/sdbd.socket %{_unitdir}/sdbd_tcp.service +%{_unitdir}/multi-user.target.wants/sdbd.service %{_prefix}/lib/udev/rules.d/99-sdbd.rules %{TZ_SYS_BIN}/profile_command %{_sysconfdir}/sdbd/descs -- 2.7.4 From a2f21a7ccaab14768d02dd891ca96c3a0e6aff7e Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:34:45 +0000 Subject: [PATCH 13/16] Revert "Change default ffs path to match system policy" This reverts commit 114ada7aa444ca588b1546f4bb6439d24f15c6ef. Change-Id: Iab74a34a89bb0e52aac9de545a23249bf2828997 --- packaging/sdbd.socket | 2 +- src/sdb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/sdbd.socket b/packaging/sdbd.socket index 8cce929..486b377 100644 --- a/packaging/sdbd.socket +++ b/packaging/sdbd.socket @@ -2,5 +2,5 @@ Description=sdbd Socket for sdb [Socket] -ListenUSBFunction=/dev/usb-funcs/sdb/default +ListenUSBFunction=/dev/usb-funcs/sdb Service=sdbd.service diff --git a/src/sdb.h b/src/sdb.h index 5be6f89..fe702c3 100644 --- a/src/sdb.h +++ b/src/sdb.h @@ -514,7 +514,7 @@ int copy_packet(apacket* dest, apacket* src); int is_emulator(void); #define DEFAULT_DEVICENAME "unknown" -#define USB_FUNCFS_SDB_PATH "/dev/usb-funcs/sdb/default/" +#define USB_FUNCFS_SDB_PATH "/dev/usb-funcs/sdb" #define USB_NODE_FILE "/dev/samsung_sdb" int create_subprocess(const char *cmd, pid_t *pid, char * const argv[], char * const envp[]); void get_env(char *key, char **env); -- 2.7.4 From bdb8cb69e466755acb7750cd6a467261c80c53ae Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:35:36 +0000 Subject: [PATCH 14/16] Revert "Remove daemonization" This reverts commit 94a707f6ecd68a9ef1c4e4ecbf519849fedad6b7. Change-Id: I9544755f829daa11b8ab0d697fc3ebed3de6caa0 --- packaging/sdbd.service | 2 +- packaging/sdbd_device.service | 2 +- packaging/sdbd_device_tv.service | 2 +- packaging/sdbd_emulator.service | 2 +- packaging/sdbd_emulator_tv.service | 2 +- packaging/sdbd_tcp.service | 2 +- src/sdb.c | 40 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 46 insertions(+), 6 deletions(-) diff --git a/packaging/sdbd.service b/packaging/sdbd.service index eb49efe..8f65db9 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -4,7 +4,7 @@ Description=sdbd [Service] #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" -Type=simple +Type=forking PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes ExecStart=/usr/sbin/sdbd diff --git a/packaging/sdbd_device.service b/packaging/sdbd_device.service index 080e0ed..38851a8 100644 --- a/packaging/sdbd_device.service +++ b/packaging/sdbd_device.service @@ -6,7 +6,7 @@ After=tmp.mount [Service] User=sdk Group=sdk -Type=simple +Type=forking #location of SDBD log file #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" diff --git a/packaging/sdbd_device_tv.service b/packaging/sdbd_device_tv.service index 88d3a08..416c818 100644 --- a/packaging/sdbd_device_tv.service +++ b/packaging/sdbd_device_tv.service @@ -4,7 +4,7 @@ Requires=tizen-system-env.service After=tmp.mount [Service] -Type=simple +Type=forking #location of SDBD log file #Environment=SDBD_LOG_PATH=/tmp #If necessary, Put Environment variable settings in a file like below diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service index 9b87f40..e6a4d3e 100644 --- a/packaging/sdbd_emulator.service +++ b/packaging/sdbd_emulator.service @@ -7,7 +7,7 @@ After=tmp.mount dbus.service [Service] User=sdk Group=sdk -Type=simple +Type=forking Environment=DISPLAY=:0 PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes diff --git a/packaging/sdbd_emulator_tv.service b/packaging/sdbd_emulator_tv.service index 3dc42e3..634974c 100644 --- a/packaging/sdbd_emulator_tv.service +++ b/packaging/sdbd_emulator_tv.service @@ -5,7 +5,7 @@ After=tmp.mount dbus.service #DefaultDependencies=false [Service] -Type=simple +Type=forking #location of SDBD log file #Environment=SDBD_LOG_PATH=/tmp #If necessary, Put Environment variable settings in a file like below diff --git a/packaging/sdbd_tcp.service b/packaging/sdbd_tcp.service index 6871f29..7ff330d 100644 --- a/packaging/sdbd_tcp.service +++ b/packaging/sdbd_tcp.service @@ -5,7 +5,7 @@ After=default.target [Service] User=sdk Group=sdk -Type=simple +Type=forking Environment=DISPLAY=:0 #If necessary, Put Environment variable settings in a file like below #ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf" diff --git a/src/sdb.c b/src/sdb.c index fe77333..cbe42b3 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1225,6 +1225,43 @@ void start_device_log(void) sdb_close(fd); } +int daemonize(void) { + + // set file creation mask to 0 + umask(0); + + switch (fork()) { + case -1: + return -1; + case 0: + break; + default: + _exit(0); + } +#ifdef SDB_PIDPATH + char* tmppath = NULL; + tmppath = realpath(SDB_PIDPATH, NULL); + if (tmppath == NULL && errno == ENOENT) { + FILE *f = fopen(SDB_PIDPATH, "w"); + + if (f != NULL) { + fprintf(f, "%d\n", getpid()); + fclose(f); + } + } else { + D("sdbd: %s file is existed. It might not work properly.\n", SDB_PIDPATH); + free(tmppath); + } +#endif + if (setsid() == -1) + return -1; + + if (chdir("/") < 0) + D("sdbd: unable to change working directory to /\n"); + + return 0; +} + /* Constructs a local name of form tcp:port. * target_str points to the target string, it's content will be overwritten. * target_size is the capacity of the target string. @@ -2265,6 +2302,9 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + if (daemonize() < 0) + fatal("daemonize() failed: errno:%d", errno); + D("Handling main()\n"); //sdbd will never die on emulator! -- 2.7.4 From 097830315da13ffac8b1bab7ffdc0ec53b08e158 Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:35:57 +0000 Subject: [PATCH 15/16] Revert "Add socket for ffs socket activation" This reverts commit cbfe04927443d0f91a28615890594460f89fe07f. Change-Id: I00e4ba798f5ffa0c7119a3c54f4f26b42e10b701 --- packaging/sdbd.service | 2 -- packaging/sdbd.socket | 6 ------ packaging/sdbd.spec | 3 --- packaging/sdbd@.socket | 6 ------ packaging/sdbd_device.service | 2 -- packaging/sdbd_device_tv.service | 2 -- packaging/sdbd_emulator.service | 2 -- 7 files changed, 23 deletions(-) delete mode 100644 packaging/sdbd.socket delete mode 100644 packaging/sdbd@.socket diff --git a/packaging/sdbd.service b/packaging/sdbd.service index 8f65db9..70b5139 100644 --- a/packaging/sdbd.service +++ b/packaging/sdbd.service @@ -8,5 +8,3 @@ Type=forking PIDFile=/tmp/.sdbd.pid RemainAfterExit=yes ExecStart=/usr/sbin/sdbd -USBFunctionDescriptors=/etc/sdbd/descs -USBFunctionStrings=/etc/sdbd/strs diff --git a/packaging/sdbd.socket b/packaging/sdbd.socket deleted file mode 100644 index 486b377..0000000 --- a/packaging/sdbd.socket +++ /dev/null @@ -1,6 +0,0 @@ -[Unit] -Description=sdbd Socket for sdb - -[Socket] -ListenUSBFunction=/dev/usb-funcs/sdb -Service=sdbd.service diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index b026aef..8cd9879 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -14,7 +14,6 @@ Source1003: %{name}.manifest Source1004: sdbd_tcp.service Source1005: sdbd_device_tv.service Source1006: sdbd_emulator_tv.service -Source1007: sdbd.socket BuildRequires: capi-system-info-devel >= 0.2.0 BuildRequires: cmake >= 2.8.3 @@ -95,7 +94,6 @@ ln -s %{_unitdir}/sdbd.service %{buildroot}/%{_unitdir}/multi-user.target.wants/ mkdir -p %{buildroot}%{_prefix}/lib/udev/rules.d/ install -m 644 rules/99-sdbd.rules %{buildroot}%{_prefix}/lib/udev/rules.d/ -install -m 0644 %SOURCE1007 %{buildroot}%{_unitdir}/sdbd.socket mkdir -p %{buildroot}%{_prefix}/sbin install -m 755 script/sdk_launch %{buildroot}%{_prefix}/sbin/ @@ -132,7 +130,6 @@ chsmack -e "User::Shell" /sbin/sdbd-user %{_prefix}/sbin/sdk_launch %attr(0755, root, root) %{_sysconfdir}/init.d/sdbd %{_unitdir}/sdbd.service -%{_unitdir}/sdbd.socket %{_unitdir}/sdbd_tcp.service %{_unitdir}/multi-user.target.wants/sdbd.service %{_prefix}/lib/udev/rules.d/99-sdbd.rules diff --git a/packaging/sdbd@.socket b/packaging/sdbd@.socket deleted file mode 100644 index d53479e..0000000 --- a/packaging/sdbd@.socket +++ /dev/null @@ -1,6 +0,0 @@ -[Unit] -Description=sdbd Socket for %I - -[Socket] -ListenUSBFunction=%I -Service=sdbd.service diff --git a/packaging/sdbd_device.service b/packaging/sdbd_device.service index 38851a8..8fe2e4a 100644 --- a/packaging/sdbd_device.service +++ b/packaging/sdbd_device.service @@ -17,8 +17,6 @@ SmackProcessLabel=System Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i SecureBits=keep-caps ExecStart=/usr/sbin/sdbd -USBFunctionDescriptors=/etc/sdbd/descs -USBFunctionStrings=/etc/sdbd/strs [Install] WantedBy=multi-user.target diff --git a/packaging/sdbd_device_tv.service b/packaging/sdbd_device_tv.service index 416c818..7ca53a3 100644 --- a/packaging/sdbd_device_tv.service +++ b/packaging/sdbd_device_tv.service @@ -16,8 +16,6 @@ Restart=on-failure Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i SecureBits=keep-caps ExecStart=/usr/sbin/sdbd -USBFunctionDescriptors=/etc/sdbd/descs -USBFunctionStrings=/etc/sdbd/strs [Install] WantedBy=multi-user.target diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service index e6a4d3e..7bf20f5 100644 --- a/packaging/sdbd_emulator.service +++ b/packaging/sdbd_emulator.service @@ -18,8 +18,6 @@ SmackProcessLabel=System Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i SecureBits=keep-caps ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`" -USBFunctionDescriptors=/etc/sdbd/descs -USBFunctionStrings=/etc/sdbd/strs [Install] WantedBy=emulator_preinit.target -- 2.7.4 From 5c68bcb8110ee5bbf1be97144589c27c5590e9e2 Mon Sep 17 00:00:00 2001 From: Adhavan M Date: Fri, 4 May 2018 10:36:17 +0000 Subject: [PATCH 16/16] Revert "Use endpoints provided by socket activation" This reverts commit 6d7244165d3c13ca69d199934ed8ffa01b8c87a0. Change-Id: I880b2a5f7e547b9239fc2c9cb00b241d51b98c3f --- CMakeLists.txt | 10 +--------- packaging/sdbd.spec | 2 -- src/usb_funcfs_client.c | 16 ++-------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 080dbcc..4416ce1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,19 +99,11 @@ IF(WEARABLE_PROFILE STREQUAL on) ADD_DEFINITIONS("-D_WEARABLE") ENDIF() -# Get systemd -pkg_check_modules(SYSTEMD REQUIRED libsystemd) -foreach(flag ${SYSTEMD_CFLAGS}) - set(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -endforeach(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") - find_package(Threads REQUIRED) ADD_EXECUTABLE(sdbd ${SDBD_SRCS}) ADD_EXECUTABLE(sdbd-user ${SDBD_SUBS}) -TARGET_LINK_LIBRARIES(sdbd -pie -lsmack -lresolv -ldl ${CMAKE_THREAD_LIBS_INIT} ${pkgs_LDFLAGS} ${SYSTEMD_LDFLAGS}) +TARGET_LINK_LIBRARIES(sdbd -pie -lsmack -lresolv -ldl ${CMAKE_THREAD_LIBS_INIT} ${pkgs_LDFLAGS}) TARGET_LINK_LIBRARIES(sdbd-user -pie ${CMAKE_THREAD_LIBS_INIT} ${pkgs_LDFLAGS}) set_property( diff --git a/packaging/sdbd.spec b/packaging/sdbd.spec index 8cd9879..8bba6c1 100644 --- a/packaging/sdbd.spec +++ b/packaging/sdbd.spec @@ -17,8 +17,6 @@ Source1006: sdbd_emulator_tv.service BuildRequires: capi-system-info-devel >= 0.2.0 BuildRequires: cmake >= 2.8.3 -BuildRequires: pkgconfig -BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(libtzplatform-config) #BuildRequires: sec-product-features BuildRequires: pkgconfig(libsmack) diff --git a/src/usb_funcfs_client.c b/src/usb_funcfs_client.c index 94f56f4..3e1ef6b 100644 --- a/src/usb_funcfs_client.c +++ b/src/usb_funcfs_client.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "sysdeps.h" @@ -139,18 +138,7 @@ static void *usb_open_thread(void *x) { struct usb_handle *usb = (struct usb_handle *)x; - /* Endpoints are received from sytemd */ - if (sd_listen_fds(0) >= 3) { - sdb_mutex_lock(&usb->control_lock); - usb->control = SD_LISTEN_FDS_START + 0; - usb->bulk_out = SD_LISTEN_FDS_START + 1; - usb->bulk_in = SD_LISTEN_FDS_START + 2; - sdb_cond_signal(&usb->control_notify); - sdb_mutex_unlock(&usb->control_lock); - } else { - init_functionfs(usb); - } - + init_functionfs(usb); if (usb->control < 0 || usb->bulk_in < 0 || usb->bulk_out < 0) { D("[ opening device failed ]\n"); return (void *)-1; @@ -406,7 +394,7 @@ void ffs_usb_init() perror("[ failed to allocate memory for usb FunctionFS bulk device ]\n"); return; } - if (sd_listen_fds(0) < 3 && autoconfig(h) < 0) { + if (autoconfig(h) < 0) { perror("[ can't recognize usb FunctionFS bulk device ]\n"); free(h); return; -- 2.7.4