Re: [systemd-devel] Stacked automount dependencies

2018-03-29 Thread Kenneth Porter
--On Friday, March 30, 2018 2:25 PM +1100 Michael Chapman 
 wrote:



This probably isn't going to work the way you want. Starting the share1
automount will itself cause share0 to be mounted, since systemd needs to
ensure that the share1 directory exists, and to mount an autofs
filesystem at this directory.

If you stack automounts in this way, the "inner" automount essentially
keeps the "outer" mount permanently in use.


That makes sense. So what I really need is a way to start the nested 
automount unit when the outer mount unit starts. The app will touch the 
outer mountpoint causing it to mount and starting the inner automount unit. 
The app may then navigate to the inner mountpoint and cause it to mount. 
But I don't need the inner automount unit to start at boot. It just needs 
to start when the outer mount completes.


So what can I put in either the outer mount unit or inner automount unit to 
make the inner automount start when the outer mount completes? 
___

systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Stacked automount dependencies

2018-03-29 Thread Michael Chapman

On Fri, 30 Mar 2018, Kenneth Porter wrote:
I need to automount a couple cifs shares on a NAS box, with one share mounted 
to a directory within another share:


/srv/share0/share1


This probably isn't going to work the way you want. Starting the share1 
automount will itself cause share0 to be mounted, since systemd needs to 
ensure that the share1 directory exists, and to mount an autofs 
filesystem at this directory.


If you stack automounts in this way, the "inner" automount essentially 
keeps the "outer" mount permanently in use.


I've created the unit files for .mount and .automount for the two shares, 
with mount disabled and automount enabled and started. This seems to work 
fine once the system is booted. But the share1 automount fails to start on 
boot with the error "dependency". The share0 automount is started and works 
when the mount point is later accessed, but not the share1 automount.


I don't know what to add to satisfy the boot-time dependency of 
srv-share0-share1.automount.


From the boot log, it looks like the system is trying to actually mount 
these shares. But the server they're being mounted from may not be up yet 
when both are powering up together. That's why I'm using an automount.


Mar 26 18:29:14 saruman kernel: CIFS VFS: Error connecting to socket. 
Aborting operation.
Mar 26 18:29:14 saruman kernel: CIFS VFS: cifs_mount failed w/return code = 
-113

Mar 26 18:29:14 saruman mount: Unable to find suitable address.
Mar 26 18:29:14 saruman systemd: srv-share0.mount mount process exited, 
code=exited status=32

Mar 26 18:29:14 saruman systemd: Failed to mount NAS1 share0.


So what's happening here is that systemd is trying to mount share0, which 
is failing...



Mar 26 18:29:14 saruman systemd: Dependency failed for Automount NAS1 share1.
Mar 26 18:29:14 saruman systemd: Job srv-share0-share1.automount/start failed 
with result 'dependency'.


... which means it can't start the automount inside it.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Stacked automount dependencies

2018-03-29 Thread Kenneth Porter
I need to automount a couple cifs shares on a NAS box, with one share 
mounted to a directory within another share:


/srv/share0/share1

I've created the unit files for .mount and .automount for the two shares, 
with mount disabled and automount enabled and started. This seems to work 
fine once the system is booted. But the share1 automount fails to start on 
boot with the error "dependency". The share0 automount is started and works 
when the mount point is later accessed, but not the share1 automount.


I don't know what to add to satisfy the boot-time dependency of 
srv-share0-share1.automount.


From the boot log, it looks like the system is trying to actually mount 
these shares. But the server they're being mounted from may not be up yet 
when both are powering up together. That's why I'm using an automount.


Mar 26 18:29:14 saruman kernel: CIFS VFS: Error connecting to socket. 
Aborting operation.
Mar 26 18:29:14 saruman kernel: CIFS VFS: cifs_mount failed w/return code = 
-113

Mar 26 18:29:14 saruman mount: Unable to find suitable address.
Mar 26 18:29:14 saruman systemd: srv-share0.mount mount process exited, 
code=exited status=32

Mar 26 18:29:14 saruman systemd: Failed to mount NAS1 share0.
Mar 26 18:29:14 saruman systemd: Dependency failed for Automount NAS1 
share1.
Mar 26 18:29:14 saruman systemd: Job srv-share0-share1.automount/start 
failed with result 'dependency'.


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Fix strerror_r segfault on non-glibc systems

2018-03-29 Thread systemd github import bot
Patchset imported to github.
To create a pull request, one of the main developers has to initiate one via:


--
Generated by https://github.com/haraldh/mail2git
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Fix strerror_r segfault on non-glibc systems

2018-03-29 Thread Lennart Poettering
On Do, 29.03.18 14:41, Ioan-Adrian Ratiu (a...@adirat.com) wrote:

> POSIX strerror_r returns an int while the glibc "extension" returns a char* 
> and
> this causes segfaults when running on systems with libc's like musl which only
> implement the portable version or deliberately don't provide a flag to 
> identify
> compiling using their headers.
> 
> Glibc provides the POSIX variant of the function, but only if _GNU_SOURCE is
> not set i.e. all gnu extensions are disabled. Meson sets _GNU_SOURCE globally
> at build time.
> 
> So detect during build if we have the char* version and #ifdef the logic.
> 
> Signed-off-by: Ioan-Adrian Ratiu 

Sorry, but as usual: please work with the other libcs to provide glibc
compatibility. At this point glibc is *the* Linux API, and it would be
much easier for everybody if the alternative libcs would just get over
themselves and provide proper compatibility, instead of expecting
people to add hacks to every single package using them.

Thank you for understanding,

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Fix strerror_r segfault on non-glibc systems

2018-03-29 Thread Paul Menzel

Dear Ioan-Adrian,


Thank you for your patch (from the future `Date: Thu, 29 Mar 2018
14:41:30 +0300`).

I believe systemd moved the development to GitHub [1] and only accepts 
merge/pull requests [1].



Please see our Contribution Guidelines for more information about
filing GitHub Issues and posting GitHub Pull Requests.



Kind regards,

Paul


[1] https://github.com/systemd/systemd/



smime.p7s
Description: S/MIME Cryptographic Signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] Fix strerror_r segfault on non-glibc systems

2018-03-29 Thread Ioan-Adrian Ratiu
POSIX strerror_r returns an int while the glibc "extension" returns a char* and
this causes segfaults when running on systems with libc's like musl which only
implement the portable version or deliberately don't provide a flag to identify
compiling using their headers.

Glibc provides the POSIX variant of the function, but only if _GNU_SOURCE is
not set i.e. all gnu extensions are disabled. Meson sets _GNU_SOURCE globally
at build time.

So detect during build if we have the char* version and #ifdef the logic.

Signed-off-by: Ioan-Adrian Ratiu 
---
 meson.build   | 13 +
 src/journal/journal-send.c|  9 +
 src/libsystemd/sd-bus/bus-error.c |  9 +
 3 files changed, 31 insertions(+)

diff --git a/meson.build b/meson.build
index b53dfaa94..fe807237f 100644
--- a/meson.build
+++ b/meson.build
@@ -383,6 +383,19 @@ if cc.compiles('''
 add_project_arguments('-Werror=shadow', language : 'c')
 endif
 
+if cc.compiles('
+   #include 
+   int func (void) {
+   char error_string[256];
+   char *ptr = strerror_r(-2, error_string, 256);
+   char c = *strerror_r(-2, error_string, 256);
+   return c != 0 && ptr != (void*) 0L;
+   }
+', name : 'strerror_r() returns char *', args : '-D_GNU_SOURCE')
+conf.set('STRERROR_R_CHAR_P', 1,
+  description: 'Defined if strerror_r returns char *')
+endif
+
 if cc.get_id() == 'clang'
 foreach arg : ['-Wno-typedef-redefinition',
'-Wno-gnu-variable-sized-type-not-at-end',
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index b6adf64c2..9b33c6c3b 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -355,7 +355,16 @@ static int fill_iovec_perror_and_send(const char *message, 
int skip, struct iove
 char* j;
 
 errno = 0;
+
+#ifdef STRERROR_R_CHAR_P
 j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k);
+#else
+j = buffer + 8 + k;
+int ret = strerror_r(_saved_errno_, j, n - 8 - k);
+if (ret)
+errno = ret;
+#endif
+
 if (errno == 0) {
 char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 
1];
 
diff --git a/src/libsystemd/sd-bus/bus-error.c 
b/src/libsystemd/sd-bus/bus-error.c
index 66a09a35f..10390f0d8 100644
--- a/src/libsystemd/sd-bus/bus-error.c
+++ b/src/libsystemd/sd-bus/bus-error.c
@@ -378,7 +378,16 @@ static void bus_error_strerror(sd_bus_error *e, int error) 
{
 return;
 
 errno = 0;
+
+#ifdef STRERROR_R_CHAR_P
 x = strerror_r(error, m, k);
+#else
+int ret = strerror_r(error, m, k);
+if (ret)
+errno = ret;
+x = m;
+#endif
+
 if (errno == ERANGE || strlen(x) >= k - 1) {
 free(m);
 k *= 2;
-- 
2.16.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel