Re: [systemd-devel] systemd-devel Digest, Vol 125, Issue 21

2020-09-08 Thread ????????
on 
making based on
  whether
   the pointer type variable "value" is pointing to 
"vbuf" or not.
   *Query*: Kindly confirm whether my understanding 
is correct.
  
   2. *Event 6* above, delete_trailing_chars(vbuf, 
NULL) is called
  outside? *if
   (value != vbuf).*
  ? ? ?This implies there may occur a situation where:
  ? ? ? ? ? ? ? ?step 1 ) *if (value != vbuf) 
*condition fails? --
  step 2 )
   *vbuf* is not initialzed inside the *if(value != 
vbuf)? *--
  step 3 )
   delete_trailing_chars(*vbuf*, NULL).
   Here, delete_trailing_chars() called for "*vbuf*" 
which is not
  necessarily
   initiazlied.
   *Query*: Kindly let me know if my understanding is 
correct or I
  am missing
   something.
  
   Thanks,
   Amit





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


-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/systemd-devel/attachments/20200908/9308c3da/attachment-0001.htm;

--

Message: 2
Date: Tue, 8 Sep 2020 15:13:22 +0100
From: Dave Howorth https://lists.freedesktop.org/mailman/listinfo/systemd-devel


--

End of systemd-devel Digest, Vol 125, Issue 21
**___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [EXT] Re: Using timedatectl on a readonly rootfile system using mender

2020-09-08 Thread Alvin Šipraga
Hi,

On 9/8/20 4:12 PM, Colin Guthrie wrote:

> 2. Set your /etc/ master image to make /etc/localtime to be a symlink to
> /run/localtime and then ensure /run/localtime is a symlink to the
> appropriate file in /usr during early boot (e.g. in initramfs). Then
> when you want to to change the timezone, just update the /run/ symlink.

This might not work as expected - systemd sometimes assumes that
/etc/localtime is a symlink into /usr/share/zoneinfo and will not
understand double symlinks. See src/basic/time-util.c:get_timezone() for
at least one example.

It's not too difficult to work around and I can provide a patch if
anybody wants it, although I don't think it will safely deal with
circular symlinks. It isn't something that upstream will be interested
in accommodating, based on Lennart's reasoning in this thread.

If you choose to go this way, /etc/localtime could also point to a
symlink on a rw mounted filesystem, allowing for writable and persistent
storage of timezone settings. But as Colin points out, you won't be able
to make such changes with systemd tooling.

The bind mount solution will probably work without patching systemd,
assuming that it doesn't disagree with the mender restrictions you
mentioned.

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


Re: [systemd-devel] libsystemd/sd_bus: trouble understanding how to parse complex responses

2020-09-08 Thread Sergey 'Jin' Bostandzhyan
Hi Lennart,

On Tue, Sep 08, 2020 at 03:58:34PM +0200, Lennart Poettering wrote:
> > Service /org/freedesktop/ModemManager1:
> > Failed to introspect object / of service /org/freedesktop/ModemManager1: 
> > Invali argument
> > No objects discovered.
> >
> > The tree looks fine, the error message is a bit weird?
> 
> Hmm, consider running this with the env var SYSTEMD_LOG_LEVEL=debug
> set, maybe that explains where the error is generated.

interestingly enough the same error does not happen today, it just returns
the tree, thanks for the log level hint though - that is indeed
very helpful!
 
> > The only things I am interested in are the paths:
> > /org/freedesktop/ModemManager1/Modem/0
> > /org/freedesktop/ModemManager1/SIM/0
> >
> > The above paths may change when the modem is replugged, so I'd like to query
> > them dynamically.
> >
> > I learned that the call to list what I need is "GetManagedObjects":
> > busctl call org.freedesktop.ModemManager1
> > /org/freedesktop/ModemManager1 org.freedesktop.DBus.ObjectManager
> > GetManagedObjects
> 
> GetManagedObjects() is only available in some services, it's an
> optional interface. "busctl" uses the XML introspection logic to
> enumerate objects, i.e. this:
>
> https://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format

Oh, so you mean that when I use "busctl call" it would detect and fake a 
GetManagedObjects() method invocation and internally use XML introspection?

That's good to know since I was using busctl to debug/test and I was assuming 
that it does the calls as instructed.

> Unlike GetManagedObjects() the XML introspection stuff is implemented
> by most services.

Understood.

Is it somehow possible to figure this out via command line tools if the
problem is in the missing GetManagedObjects() implementation or not?

> > while (sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{oa{sa{sv}}}") 
> > > 0)
> > {
> 
> Hmm, this is what you'd write when you have an array of arrays...

Uhm, how do I correctly "enter" a container like this one: "a{oa{sa{sv}}}" ?

I guess this is correct, what GetManagedObjects() returns is an array of
dictionaries "a{oa{sa{sv}}}" or am I misinterpreting it?
 
> sd_bus_message_enter_container() returns < 0 on error, == 0 if we
> reached the end of the surrounding container, and > 0 if all was
> good. I'd recommend checking for error cases which you ignore
> here. The errors tell you where things go wrong.

I already had error checks everywhere except loops, so I added that now.

sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "oa{sa{sv}}")
returns 1 on the first call, thats where I get the first path that
equals to "/org/freedesktop/ModemManager1/Modem/0" and it returns 0 on the
next invocation.

This leads me to the next question below...

> Normally, you#d enter the array once and then iterate through the
> dict entries contained therein. i.e. unless there's an "aa" object
> somewhere (i.e. "array of array") you'd do the while loop around the
> dict entries, not the array object.

Could you please clarify how iteration works in sd_bus sense? Is my 
understanding correct that I need to use sd_bus_message_skip() before
exiting the container in order to iterate to the next item, if I am not
interested in parsing all of the nested items? Or can I just "exit" at any
time and expect the next "enter" invocation to fast forward to the
next entry?

Based on what you are saying the inner while loop that I had right after
entering the array should have returned all items. So I start by entering
the array:

// starting with a{oa{sa{sv}}}
sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{oa{sa{sv}}}")

And loop over dictionary key-value pairs:

// brings me down into oa{sa{sv}}}, I am only interested in the object paths:
while (sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "oa{sa{sv}}") 
> 0) {
sd_bus_message_read_basic(m, SD_BUS_TYPE_OBJECT_PATH, );
sd_bus_message_skip(m, "a{sa{sv}}");
sd_bus_message_exit_container(m);
}

Does the above look correct? As mentioned, I am not getting errors, return
codes are fine, so it all looks normal, but I am only reading out
the first path, on the second iteration
sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "oa{sa{sv}}") returns 
0 which aborts the loop.

At this point I am not sure if sd_bus actually behaves correctly and
GetManagedObjects() returns only one path or if I messed up the parsing of
the reply somehow? And I am not sure how to check that...

I would like to avoid parsing XML if I can, but of course that option is
still there; nevertheless, I would first like to understand what is going on 
with the GetManagedObjects() call and if the problem is really there or 
somewhere else.

Kind regars,
Jin

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


Re: [systemd-devel] [EXT] Re: Using timedatectl on a readonly rootfile system using mender

2020-09-08 Thread juice

Shravan Singh kirjoitti 2020-09-08 16:31:

No one is answering a simple question. Why we have to guard timezone
so much?.

Why can't I change it? What happens if I change it on a read-only
rootfs? I am breaking the whole systemd by doing this?

In fact most of the people in this group are suggesting a work-around
to me

 "I wonder: If you have a working pull request, why don't you use that
code and be happy with it? That's how free software works.
Still everybody interested can apply you patch."

Yes, it works. My question is why is not getting included so that
everyone can benefit from it. That is how a free software community
should work.


It's a general doubt about usefulness. I don't think your need is so
general that many people would benefit from it and it breaks conventions
that have been used for quite long time.


In this day and age of mobile computing it is really shocking to see.
That timezone is not regarded as something that can be dynamically
changed.


No, that is not the problem here. TZ is freely changeable and always
has been, your problem is the read-only /etc.

You should take this up with mender and not systemd; fix it where it is
broken and don't try to patch it somewhere else.

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


Re: [systemd-devel] Why systemd keeps references on passed sockets ?

2020-09-08 Thread Lennart Poettering
On Di, 08.09.20 17:35, Francis Moreau (francis.m...@gmail.com) wrote:

> On Mon, Sep 7, 2020 at 4:38 PM Lennart Poettering
>  wrote:
> >
> > "React on the socket close?" — What do you mean by that?
> >
>
> I mean if my service explicitly calls close() then systemd could stop
> the socket on its side so its are freed until the service is
> restarted. I think it is what you described below.

close() just drops a ref to the socket. Only when close() drops the
last ref something actually happens on the socket and it is
destroyed. This means: systemd doesn't get notified about your code
invoking close(), because all you did is drop one ref of many.

> > Note that on Linux you can invoke shutdown() on a listening socket
> > (i.e. not just on the connection socket, but on a listening
> > socket). iirc in that case systemd actually notices and will put the
> > .socket unit in failure mode...
> >
>
> I looked at the code and there is:
>
> if (state != SOCKET_LISTENING)
> socket_unwatch_fds(s);
>
> So I'm not sure how systemd can react on shutdown(). And I tried to
> call shutdown() in my service but it has no effects.

Hmm, that suggests we'd have to slightly update our logic then for
this to work: keep the listening fds in the poll, but turn off all
the EPOLLIN bit we listen on.

> > Would that work for you? (Maybe we could even tweak this a bit in
> > systemd, so that when you invoke shutdown() on the socket systemd
> > holds for you we do not consider that a failure anymore, but a clean
> > way to tell systemd to stop the socket).
>
> That is a good idea especially if systemd doesn't consider an error
> when the service closes or shutdown the socket.
>
> But again in the code I can see:
>
>   sd_event_add_io(UNIT(s)->manager->event, >event_source, p->fd,
> EPOLLIN, socket_dispatch_io, p);
>
> It seems that it only listens to "EPOLLIN" events. So it doesn't
> listen to "EPOLLUP".

EPOLLHUP is always implied, you don't have to specify it. if you
specifiy zero as mask you will still get notified about EPOLLHUP +
EPOLLERR.

But you are right we currently remove the fd from polling while the
socket's service is running. We'd have to change that (as mentioned
above). happy to review a PR for that.

Lennart

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


Re: [systemd-devel] Why systemd keeps references on passed sockets ?

2020-09-08 Thread Francis Moreau
On Mon, Sep 7, 2020 at 4:38 PM Lennart Poettering
 wrote:
>
> "React on the socket close?" — What do you mean by that?
>

I mean if my service explicitly calls close() then systemd could stop
the socket on its side so its are freed until the service is
restarted. I think it is what you described below.

> Note that on Linux you can invoke shutdown() on a listening socket
> (i.e. not just on the connection socket, but on a listening
> socket). iirc in that case systemd actually notices and will put the
> .socket unit in failure mode...
>

I looked at the code and there is:

if (state != SOCKET_LISTENING)
socket_unwatch_fds(s);

So I'm not sure how systemd can react on shutdown(). And I tried to
call shutdown() in my service but it has no effects.

> Would that work for you? (Maybe we could even tweak this a bit in
> systemd, so that when you invoke shutdown() on the socket systemd
> holds for you we do not consider that a failure anymore, but a clean
> way to tell systemd to stop the socket).

That is a good idea especially if systemd doesn't consider an error
when the service closes or shutdown the socket.

But again in the code I can see:

  sd_event_add_io(UNIT(s)->manager->event, >event_source, p->fd,
EPOLLIN, socket_dispatch_io, p);

It seems that it only listens to "EPOLLIN" events. So it doesn't
listen to "EPOLLUP".

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


Re: [systemd-devel] Antw: [EXT] Re: Q: Start a unit n minutes after a successful boot

2020-09-08 Thread Lennart Poettering
On Di, 08.09.20 11:01, Ulrich Windl (ulrich.wi...@rz.uni-regensburg.de) wrote:

> >> Configuring a new system with non‑redundant system disk I'm wondering:
> >> How could I start an automatic backup job that is triggered n minutes
> >> after the system started successfully (to avoid backing up broken
> >> configurations)?
> >
> >   Timer with "OnBootSec=n minutes" is exactly what you want, right?
>
> Hi!
>
> Is every boot a successful boot? Will (e.g.) default.target be reached even if
> some service failed? If not, that is what I had in mind:
> Start a unit n minutes after default.target was reached
> "sucessfully".

Define a timer unit like this if you want to make this dependent on
"default.target" having been reached.

[Unit]
Requisite=default.target
After=default.target

[Timer]
OnActiveSec=2min

[Install]
WantedBy=timers.target

This will enqueue the timer during early boot, but not actually
activate it until default.target has been reached. Then once active,
after 2mn the associated service is triggered.

Lennart

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


Re: [systemd-devel] socket: Failed to queue service startup job: Transport endpoint is not connected

2020-09-08 Thread Lennart Poettering
On Mo, 07.09.20 14:22, Alec Moskvin (al...@gmx.com) wrote:

> A few days ago I tried to ssh into one of my boxes (which was using
> socket-activated per-connection ssh) but got connection refused. Luckily
> I had another ssh session open. In the journal, the only relevant thing
> logged was:
>
>   systemd[1]: sshd.socket: Failed to queue service startup job (Maybe the 
> service file is missing or not a template unit?): Transport endpoint is not 
> connected
>   systemd[1]: sshd.socket: Failed with result 'resources'.
>
> I started the socket back up and could connect again. The system had
> been mostly idle and there were no upgrades since it booted up 2 days
> earlier. The previous ssh login attempt was 4 hours before.

It's a bug. Should be fixed by 86e045ecefc404d4fccbeb78aa212ec4714a5763.

Lennart

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


Re: [systemd-devel] Q: Start a unit n minutes after a successful boot

2020-09-08 Thread Lennart Poettering
On Di, 08.09.20 09:21, Ulrich Windl (ulrich.wi...@rz.uni-regensburg.de) wrote:

> Hi!
>
> Configuring a new system with non-redundant system disk I'm
> wondering: How could I start an automatic backup job that is
> triggered n minutes after the system started successfully (to avoid
> backing up broken configurations)?

What does "started successfully" mean to you?

Lennart

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


Re: [systemd-devel] [EXT] Initialization of "vbuf" in function "token_match_attr"

2020-09-08 Thread Josef Möllers
On 08.09.20 16:03, Amit anand wrote:
> Hi,
>
> On Tue, Sep 8, 2020 at 6:23 PM Ulrich Windl
>  > wrote:
>
> Hi!
>
> vbuf is initialized: It has some address on the stack, so "if
> (value != vbuf)" is comparing adresses, if I got it right...
>
> vbuf having some address on stack and "if(value!=vbuf)" is comparing
> addresses doesn't necessarily implies that vbuf is initialized.
> I am still not clear about where vbuf is initialized.

It is initialized with the strscpy() call.

The comparison just compares the pointer in *value (+) with the ADDRESS
of "vbuf"!

(+) Please ignore my previous remark. I don't know what I had been
smoking at that time!

So if "value" does not point at "vbuf", it points at some other buffer,
but the data in that buffer should be in "vbuf", so the contents of the
buffer "value" points at is copied into the buffer named "vbuf"!

If "value" points at "vbuf", the call to "sd_device_get_sysattr_value"
would have  already put the data into "vbuf" and thus the strscpy()
would not be needed, as it would copy "vbuf" into itself.

HTH,

Josef

> Also, expecting some information regarding my queries in below mail.
>
> Thanks,
> Amit
>
>
> >>> Amit anand  > schrieb am 08.09.2020 um 13:56 in
> Nachricht
>  >:
> > Hi systemd-devel team,
> >
> > I am trying to understand where "vbuf" is initialized in function
> > "token_match_attr()" in file udev-rules.c
> >
> > Below code snippet :
> > static bool* token_match_attr*(UdevRuleToken *token, sd_device *dev,
> > UdevEvent *event) {
> >  *char* nbuf[UTIL_NAME_SIZE], *vbuf*[UTIL_NAME_SIZE];     //
> Here, vbuf is
> > defined, however not initialized.
> > *const char* *name, **value;        *// Here, value is declared
> to be of
> > type const char *, however, not initialized.
> > ...
> > ... // some code
> > ...
> > switch (token->attr_subst_type) {   // *Event 1* : This evaluates to
> > SUBST_TYPE_PLAIN
> > ...
> > case *SUBST_TYPE_PLAIN*:   if (sd_device_get_sysattr_value(dev,
> name,
> > ) < 0)   // *Event 2* :The if condition evaluates to false.
> >                                                  return false;
> >  break;
> > ...// some code
> > ...
> > }
> >
> >         if (token->attr_match_remove_trailing_whitespace) {     
> // *Event
> > 4*: If condition evaluates to true
> >                 if (value != vbuf) {      //  *Event 5* : vbuf
> and value
> > are both declared but not initialized. Comparison is done without
> > initializing "vbuf" and "value".
> >                         strscpy(vbuf, sizeof(vbuf), value);
> >                         value = vbuf;
> >                 } // End of if.
> >
> >                 delete_trailing_chars(vbuf, NULL);         //
> *Event 6*:
> > trying to delete trailing chars from "vbuf" which is not
> initialzed. ??
> >         } // End of outer if.
> > ... // some code
> > } /End of function : *token_match_attr()*
> >
> > Below are my queries :
> > 1. *Event 5 *above, we are comparing two resources ("value" and
> "vbuf")
> > even before initializing them.
> >     Are we doing this comparision to do decision making based on
> whether
> > the pointer type variable "value" is pointing to "vbuf" or not.
> > *Query*: Kindly confirm whether my understanding is correct.
> >
> > 2. *Event 6* above, delete_trailing_chars(vbuf, NULL) is called
> outside  *if
> > (value != vbuf).*
> >     This implies there may occur a situation where:
> >               step 1 ) *if (value != vbuf) *condition fails  -->
> step 2 )
> > *vbuf* is not initialzed inside the *if(value != vbuf)  *-->
> step 3 )
> > delete_trailing_chars(*vbuf*, NULL).
> > Here, delete_trailing_chars() called for "*vbuf*" which is not
> necessarily
> > initiazlied.
> > *Query*: Kindly let me know if my understanding is correct or I
> am missing
> > something.
> >
> > Thanks,
> > Amit
>
>
>
>
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel


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


Re: [systemd-devel] Journal message timestamps

2020-09-08 Thread Dave Howorth
On Tue, 8 Sep 2020 07:18:15 -0400
"Kevin P. Fleming"  wrote:
> On Tue, Sep 8, 2020 at 7:12 AM Reindl Harald 
> wrote:
> 
> > your playground is in
> > /etc/systemd/system/fake-hwclock.service.d/myoverrides.conf
> >
> > and yes that is important so that you don#t have to redo your
> > changes after each and every update and way better than cloning the
> > whole unit-file in /etc/systemd/system/ so that reasonable upstream
> > changes get applied in teh future
> >
> > -
> >
> > /etc/systemd/system/fake-hwclock.service.d/myoverrides.conf:
> >
> > [Unit]
> > Before=systemd-journald.service  
> 
> ... and this is most easily done by using 'systemctl edit
> fake-hwclock.service', which will create the file in the proper
> location so you don't have to (and will handily cause a daemon reload
> as well).

Hi Mark, Reindl, Kevin, et al,

I have added

[Unit]
Before=systemd-journald.service

to a drop-in file in /etc/systemd/system/fake-hwclock.service.d/ so
hopefully it will get tested next time the machines reboot (they're
production data loggers so I don't want to reboot unnecessarily).

I had appreciated it should be done via an override file but thanks for
the warning. I'd forgotten about the edit command so I had done it the
hard way :) I don't think a daemon reload is necessary in this case,
since it only affects matters on the next and subsequent boots anyway.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [EXT] Re: Using timedatectl on a readonly rootfile system using mender

2020-09-08 Thread Colin Guthrie
It's not specifically guarded. Dynamic stuff like networking is
specifically excluded. Timezone is pretty much the same as any other
config, in that if you want to change it make sure you can save it.

I'd argue that dynamically changing timezone for the duration of a boot
is not that common.

If you really want it to be dynamic, you can either:

1. Bind mount over the top of /etc/localtime to a writable file on boot.
Update it's contents whenever you want to change the timezone.

2. Set your /etc/ master image to make /etc/localtime to be a symlink to
/run/localtime and then ensure /run/localtime is a symlink to the
appropriate file in /usr during early boot (e.g. in initramfs). Then
when you want to to change the timezone, just update the /run/ symlink.

Both will work fine. You can do this if you really want to and no-one is
stopping you, it's just that the systemd-blessed tool to update the
content in /etc won't do that, just like it won't do that for numerous
other stuff too.

Everyone sees the problem (and often the solution) they have in front of
them as the most obvious thing in the world, but some perspective is
often needed to see it as others do.

Col




Shravan Singh wrote on 08/09/2020 14:31:
> No one is answering a simple question. Why we have to guard timezone so
> much?.
> Why can't I change it? What happens if I change it on a read-only
> rootfs? I am breaking the whole systemd by doing this?
> 
> In fact most of the people in this group are suggesting a work-around to me
> 
> "I wonder: If you have a working pull request, why don't you use that
> code and be happy with it? That's how free software works.
> Still everybody interested can apply you patch."
> 
> Yes, it works. My question is why is not getting included so that
> everyone can benefit from it. That is how a free software community
> should work.
> 
> In this day and age of mobile computing it is really shocking to see.
> That timezone is not regarded as something that can be dynamically changed.
> 
> Anyway this issue is going no-further if people are adamant in not
> changing it.
> And I don't see any reason in going back and forth with everyone.
> 
> 
> Regards,
> Shravan Singh
> (239) 243-0838
> 
> Blue Sparq, Inc.
> 928 NE 24th Lane unit 4 and 5.
> Cape Coral, FL 33993
> 
> IMPORTANT: The contents of this email and any attachments are
> confidential. They are intended for the named recipient(s) only. If you
> have received this email by mistake, please notify the sender
> immediately and do not disclose the contents to anyone or make copies
> thereof.
> 
> 
> On Mon, Sep 7, 2020 at 4:49 AM Ulrich Windl
>  > wrote:
> 
> >>> Shravan Singh  > schrieb am 05.09.2020 um 00:26 in
> Nachricht
>  >:
> > And this is a major problem for any one running raspberry pi, NXP
> or any
> > other embedded processor that uses mender and embedded linux.
> 
> Maybe an embedded OS really should use UTC as timezone.
> 
> > A machine with embedded linux running on it goes to San Francisco
> and then
> > transported to Chicago.
> > And you are saying that we shouldn't be allowed to change the
> timezone?
> 
> The question is : Who will "see" the timezone? Does every process
> run with the same timezone?
> 
> > Just because you are not "convinced"
> > Does this group have a poll system? Let's put this to poll and see?
> 
> I wonder: If you have a working pull request, why don't you use that
> code and be happy with it? That's how free software works.
> Still everybody interested can apply you patch.
> >
> > I have tried having a rational explanation with you but your
> attitude is
> > just appalling
> >
> > I have tried this solution and it works
> > https://github.com/systemd/systemd/pull/8277.
> > I just don't understand why you are not willing to accept this.
> And provide
> > a solution to all the people using raspberry pi and or embedded
> processors?
> >
> >
> >
> >
> > Regards,
> > Shravan Singh
> > (239) 243-0838
> >
> > Blue Sparq, Inc.
> > 928 NE 24th Lane unit 4 and 5.
> > Cape Coral, FL 33993
> >
> > IMPORTANT: The contents of this email and any attachments are
> confidential.
> > They are intended for the named recipient(s) only. If you have
> received
> > this email by mistake, please notify the sender immediately and do not
> > disclose the contents to anyone or make copies thereof.
> >
> >
> > On Fri, Sep 4, 2020 at 6:16 PM Shravan Singh
> mailto:shra...@bluesparq.com>> wrote:
> >
> >> What constitutes a configuration?
> >> And please read my email subject. I can't have writable /etc, mender
> >> dosen't allow that.
> >>
> >> In today's mobile computing age 

Re: [systemd-devel] Alias use in socket file

2020-09-08 Thread Lennart Poettering
On Di, 08.09.20 08:45, Belisko Marek (marek.beli...@gmail.com) wrote:

> Hi,
>
> I'm using yocto build systemd and I'm using openssh server which
> create sshd.socket + sshd@.service files. With socket I can control if
> ssh is enabled / disabled. I have an application which expects to
> check statu of ssh.service. I tried to add Alias=ssh.service to
> sshd.socket file and tried systemd enable sshd.socket but systemd
> cannot see ssh.service. Is there some other way to create a link to an
> existing socket file? Thanks

No, systemd refuses to recognize unit symlinks that change unit type
(i.e. the unit suffix after the dot) as aliases. It also doesn't
accept symlinks that change if a unit is templated or not. Objects
can't magically change their type, and they cannot suddenly
become/stop being templated or not.

Sorry,

Lennart

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


Re: [systemd-devel] [EXT] Initialization of "vbuf" in function "token_match_attr"

2020-09-08 Thread Amit anand
Hi,

On Tue, Sep 8, 2020 at 6:23 PM Ulrich Windl <
ulrich.wi...@rz.uni-regensburg.de> wrote:

> Hi!
>
> vbuf is initialized: It has some address on the stack, so "if (value !=
> vbuf)" is comparing adresses, if I got it right...
>
vbuf having some address on stack and "if(value!=vbuf)" is comparing
addresses doesn't necessarily implies that vbuf is initialized.
I am still not clear about where vbuf is initialized.
Also, expecting some information regarding my queries in below mail.

Thanks,
Amit

>
> >>> Amit anand  schrieb am 08.09.2020 um 13:56 in
> Nachricht
> :
> > Hi systemd-devel team,
> >
> > I am trying to understand where "vbuf" is initialized in function
> > "token_match_attr()" in file udev-rules.c
> >
> > Below code snippet :
> > static bool* token_match_attr*(UdevRuleToken *token, sd_device *dev,
> > UdevEvent *event) {
> >  *char* nbuf[UTIL_NAME_SIZE], *vbuf*[UTIL_NAME_SIZE]; // Here, vbuf
> is
> > defined, however not initialized.
> > *const char* *name, **value;*// Here, value is declared to be of
> > type const char *, however, not initialized.
> > ...
> > ... // some code
> > ...
> > switch (token->attr_subst_type) {   // *Event 1* : This evaluates to
> > SUBST_TYPE_PLAIN
> > ...
> > case *SUBST_TYPE_PLAIN*:   if (sd_device_get_sysattr_value(dev, name,
> > ) < 0)   // *Event 2* :The if condition evaluates to false.
> >  return false;
> >  break;
> > ...// some code
> > ...
> > }
> >
> > if (token->attr_match_remove_trailing_whitespace) {  //
> *Event
> > 4*: If condition evaluates to true
> > if (value != vbuf) {  //  *Event 5* : vbuf and value
> > are both declared but not initialized. Comparison is done without
> > initializing "vbuf" and "value".
> > strscpy(vbuf, sizeof(vbuf), value);
> > value = vbuf;
> > } // End of if.
> >
> > delete_trailing_chars(vbuf, NULL); // *Event 6*:
> > trying to delete trailing chars from "vbuf" which is not initialzed. ??
> > } // End of outer if.
> > ... // some code
> > } /End of function : *token_match_attr()*
> >
> > Below are my queries :
> > 1. *Event 5 *above, we are comparing two resources ("value" and "vbuf")
> > even before initializing them.
> > Are we doing this comparision to do decision making based on whether
> > the pointer type variable "value" is pointing to "vbuf" or not.
> > *Query*: Kindly confirm whether my understanding is correct.
> >
> > 2. *Event 6* above, delete_trailing_chars(vbuf, NULL) is called outside
> *if
> > (value != vbuf).*
> > This implies there may occur a situation where:
> >   step 1 ) *if (value != vbuf) *condition fails  --> step 2 )
> > *vbuf* is not initialzed inside the *if(value != vbuf)  *--> step 3 )
> > delete_trailing_chars(*vbuf*, NULL).
> > Here, delete_trailing_chars() called for "*vbuf*" which is not
> necessarily
> > initiazlied.
> > *Query*: Kindly let me know if my understanding is correct or I am
> missing
> > something.
> >
> > Thanks,
> > Amit
>
>
>
>
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Antw: [EXT] Re: User/Group overrides in a templated service triggered via timer

2020-09-08 Thread Lennart Poettering
On Mo, 07.09.20 14:19, Kevin P. Fleming (ke...@km6g.us) wrote:

> On Mon, Sep 7, 2020 at 11:58 AM Lennart Poettering
>  wrote:
> > Not sure I can parse this. Both timers and services are units in
> > systemd. You can enable timer units, and you can enable service units,
> > it all depends on what you put in their [Install] section. Sometimes
> > it makes sense to add an [Install] section to one, sometimes to the
> > other, sometimes to both, dependning on what the triggers should be
> > that you want to use. Pretty often it might make sense to include just
> > an Also=foobar.timer in the [Install] section of foobar.service, which
> > then means that if the service is enabled, foobar.timer is enabled
> > implicitly.
>
> Hindsight being 20/20, it would probably have made more sense to users
> if the command was 'systemctl install' since that would match the
> section name in the unit file. It's a bit late for that now :-)

It actually was named like that originally, a long long time ago.

We nowadays use "install" as generic terminology for "enable",
"disable", "mask" and so on, i.e. for any form of hooking stuff in or
out.



Lennart

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


Re: [systemd-devel] libsystemd/sd_bus: trouble understanding how to parse complex responses

2020-09-08 Thread Lennart Poettering
On Mo, 07.09.20 19:40, Sergey 'Jin' Bostandzhyan (j...@mediatomb.cc) wrote:

> Hi,
>
> I have spent quite some time on this, but I don't seem to be getting
> anywhere, so I hope someone could point me in the right direction.
>
> I am learning sd_bus, my goal is to get a list of available modem services
> from ModemManager. To make sure that what I am looking for is actually there,
> I first checked with busctl:
>
> Service org.freedesktop.ModemManager1:
> └─/org
>   └─/org/freedesktop
> └─/org/freedesktop/ModemManager1
>   ├─/org/freedesktop/ModemManager1/Modem
>   │ └─/org/freedesktop/ModemManager1/Modem/0
>   └─/org/freedesktop/ModemManager1/SIM
> └─/org/freedesktop/ModemManager1/SIM/0
>
> Service /org/freedesktop/ModemManager1:
> Failed to introspect object / of service /org/freedesktop/ModemManager1: 
> Invali argument
> No objects discovered.
>
> The tree looks fine, the error message is a bit weird?

Hmm, consider running this with the env var SYSTEMD_LOG_LEVEL=debug
set, maybe that explains where the error is generated.

> The only things I am interested in are the paths:
> /org/freedesktop/ModemManager1/Modem/0
> /org/freedesktop/ModemManager1/SIM/0
>
> The above paths may change when the modem is replugged, so I'd like to query
> them dynamically.
>
> I learned that the call to list what I need is "GetManagedObjects":
> busctl call org.freedesktop.ModemManager1
> /org/freedesktop/ModemManager1 org.freedesktop.DBus.ObjectManager
> GetManagedObjects

GetManagedObjects() is only available in some services, it's an
optional interface. "busctl" uses the XML introspection logic to
enumerate objects, i.e. this:

https://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format

Unlike GetManagedObjects() the XML introspection stuff is implemented
by most services.

> while (sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{oa{sa{sv}}}") > 
> 0)
> {

Hmm, this is what you'd write when you have an array of arrays...

sd_bus_message_enter_container() returns < 0 on error, == 0 if we
reached the end of the surrounding container, and > 0 if all was
good. I'd recommend checking for error cases which you ignore
here. The errors tell you where things go wrong.

Normally, you#d enter the array once and then iterate through the
dict entries contained therein. i.e. unless there's an "aa" object
somewhere (i.e. "array of array") you'd do the while loop around the
dict entries, not the array object.

Lennart

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


Re: [systemd-devel] [EXT] Re: Using timedatectl on a readonly rootfile system using mender

2020-09-08 Thread Shravan Singh
No one is answering a simple question. Why we have to guard timezone so
much?.
Why can't I change it? What happens if I change it on a read-only rootfs? I
am breaking the whole systemd by doing this?

In fact most of the people in this group are suggesting a work-around to me

"I wonder: If you have a working pull request, why don't you use that code
and be happy with it? That's how free software works.
Still everybody interested can apply you patch."

Yes, it works. My question is why is not getting included so that everyone
can benefit from it. That is how a free software community should work.

In this day and age of mobile computing it is really shocking to see. That
timezone is not regarded as something that can be dynamically changed.

Anyway this issue is going no-further if people are adamant in not changing
it.
And I don't see any reason in going back and forth with everyone.


Regards,
Shravan Singh
(239) 243-0838

Blue Sparq, Inc.
928 NE 24th Lane unit 4 and 5.
Cape Coral, FL 33993

IMPORTANT: The contents of this email and any attachments are confidential.
They are intended for the named recipient(s) only. If you have received
this email by mistake, please notify the sender immediately and do not
disclose the contents to anyone or make copies thereof.


On Mon, Sep 7, 2020 at 4:49 AM Ulrich Windl <
ulrich.wi...@rz.uni-regensburg.de> wrote:

> >>> Shravan Singh  schrieb am 05.09.2020 um 00:26
> in
> Nachricht
> :
> > And this is a major problem for any one running raspberry pi, NXP or any
> > other embedded processor that uses mender and embedded linux.
>
> Maybe an embedded OS really should use UTC as timezone.
>
> > A machine with embedded linux running on it goes to San Francisco and
> then
> > transported to Chicago.
> > And you are saying that we shouldn't be allowed to change the timezone?
>
> The question is : Who will "see" the timezone? Does every process run with
> the same timezone?
>
> > Just because you are not "convinced"
> > Does this group have a poll system? Let's put this to poll and see?
>
> I wonder: If you have a working pull request, why don't you use that code
> and be happy with it? That's how free software works.
> Still everybody interested can apply you patch.
> >
> > I have tried having a rational explanation with you but your attitude is
> > just appalling
> >
> > I have tried this solution and it works
> > https://github.com/systemd/systemd/pull/8277.
> > I just don't understand why you are not willing to accept this. And
> provide
> > a solution to all the people using raspberry pi and or embedded
> processors?
> >
> >
> >
> >
> > Regards,
> > Shravan Singh
> > (239) 243-0838
> >
> > Blue Sparq, Inc.
> > 928 NE 24th Lane unit 4 and 5.
> > Cape Coral, FL 33993
> >
> > IMPORTANT: The contents of this email and any attachments are
> confidential.
> > They are intended for the named recipient(s) only. If you have received
> > this email by mistake, please notify the sender immediately and do not
> > disclose the contents to anyone or make copies thereof.
> >
> >
> > On Fri, Sep 4, 2020 at 6:16 PM Shravan Singh 
> wrote:
> >
> >> What constitutes a configuration?
> >> And please read my email subject. I can't have writable /etc, mender
> >> dosen't allow that.
> >>
> >> In today's mobile computing age you really think users shouldn't change
> >> timezone?
> >> You keep saying " I for one am certainly not convinced that the
> timezones"
> >> but you don't explain why?
> >> Are you looking at this system as a static machine? That can never
> change
> >> timezone?
> >>
> >> And please don't use profanity. I have not and you shouldn't either.
> >>
> >> Regards,
> >> Shravan Singh
> >> (239) 243-0838
> >>
> >> Blue Sparq, Inc.
> >> 928 NE 24th Lane unit 4 and 5.
> >> Cape Coral, FL 33993
> >>
> >> IMPORTANT: The contents of this email and any attachments are
> >> confidential. They are intended for the named recipient(s) only. If you
> >> have received this email by mistake, please notify the sender
> immediately
> >> and do not disclose the contents to anyone or make copies thereof.
> >>
> >>
> >> On Fri, Sep 4, 2020 at 6:05 PM Lennart Poettering <
> lenn...@poettering.net>
> >> wrote:
> >>
> >>> On Fr, 04.09.20 15:54, Shravan Singh (shra...@bluesparq.com) wrote:
> >>>
> >>> > Yes, But help me understand.
> >>> > I think you said that you are not convinced as to why that has to
> done.
> >>> >
> >>> > My argument is very simple shouldn't a Linux environment allow
> change in
> >>> > timezone easily?
> >>>
> >>> Oh we do. But if your want configuration to be changable, then mount
> >>> /etc writable.
> >>>
> >>> You have two contradicting goals: you want immutable config, but then
> >>> you want to change config. So how's that gonna work?
> >>>
> >>> If you want your persistent config changable then make it changable,
> >>> i.e. mount /etc/ writable.
> >>>
> >>> > Now I am not an expert in Linux kernel development. But I see that
> some
> >>> of
> >>> > the files, even 

Re: [systemd-devel] Antw: [EXT] Initialization of "vbuf" in function "token_match_attr"

2020-09-08 Thread Josef Möllers
On 08.09.20 14:53, Ulrich Windl wrote:
> Hi!
>
> vbuf is initialized: It has some address on the stack, so "if (value != 
> vbuf)" is comparing adresses, if I got it right...

You got it right, but I stumble across this (in essence):

char vbuf[UTIL_NAME_SIZE];
char **value;
if (value != vbuf)
    strscpy(vbuf, sizeof(vbuf), value);

"vbuf" has a type of "pointer to char" and "values" has type "pointer to
pointer to char". The logic dictates that "value" should also be "just"
a "char *value".

But I guess that's a copy-paste-error.

Josef

>
 Amit anand  schrieb am 08.09.2020 um 13:56 in 
 Nachricht
> :
>> Hi systemd-devel team,
>>
>> I am trying to understand where "vbuf" is initialized in function
>> "token_match_attr()" in file udev-rules.c
>>
>> Below code snippet :
>> static bool* token_match_attr*(UdevRuleToken *token, sd_device *dev,
>> UdevEvent *event) {
>>  *char* nbuf[UTIL_NAME_SIZE], *vbuf*[UTIL_NAME_SIZE]; // Here, vbuf is
>> defined, however not initialized.
>> *const char* *name, **value;*// Here, value is declared to be of
>> type const char *, however, not initialized.
>> ...
>> ... // some code
>> ...
>> switch (token->attr_subst_type) {   // *Event 1* : This evaluates to
>> SUBST_TYPE_PLAIN
>> ...
>> case *SUBST_TYPE_PLAIN*:   if (sd_device_get_sysattr_value(dev, name,
>> ) < 0)   // *Event 2* :The if condition evaluates to false.
>>  return false;
>>  break;
>> ...// some code
>> ...
>> }
>>
>> if (token->attr_match_remove_trailing_whitespace) {  // *Event
>> 4*: If condition evaluates to true
>> if (value != vbuf) {  //  *Event 5* : vbuf and value
>> are both declared but not initialized. Comparison is done without
>> initializing "vbuf" and "value".
>> strscpy(vbuf, sizeof(vbuf), value);
>> value = vbuf;
>> } // End of if.
>>
>> delete_trailing_chars(vbuf, NULL); // *Event 6*:
>> trying to delete trailing chars from "vbuf" which is not initialzed. ??
>> } // End of outer if.
>> ... // some code
>> } /End of function : *token_match_attr()*
>>
>> Below are my queries :
>> 1. *Event 5 *above, we are comparing two resources ("value" and "vbuf")
>> even before initializing them.
>> Are we doing this comparision to do decision making based on whether
>> the pointer type variable "value" is pointing to "vbuf" or not.
>> *Query*: Kindly confirm whether my understanding is correct.
>>
>> 2. *Event 6* above, delete_trailing_chars(vbuf, NULL) is called outside  *if
>> (value != vbuf).*
>> This implies there may occur a situation where:
>>   step 1 ) *if (value != vbuf) *condition fails  --> step 2 )
>> *vbuf* is not initialzed inside the *if(value != vbuf)  *--> step 3 )
>> delete_trailing_chars(*vbuf*, NULL).
>> Here, delete_trailing_chars() called for "*vbuf*" which is not necessarily
>> initiazlied.
>> *Query*: Kindly let me know if my understanding is correct or I am missing
>> something.
>>
>> Thanks,
>> Amit
>
>
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>

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


[systemd-devel] Antw: [EXT] Initialization of "vbuf" in function "token_match_attr"

2020-09-08 Thread Ulrich Windl
Hi!

vbuf is initialized: It has some address on the stack, so "if (value != vbuf)" 
is comparing adresses, if I got it right...

>>> Amit anand  schrieb am 08.09.2020 um 13:56 in 
>>> Nachricht
:
> Hi systemd-devel team,
> 
> I am trying to understand where "vbuf" is initialized in function
> "token_match_attr()" in file udev-rules.c
> 
> Below code snippet :
> static bool* token_match_attr*(UdevRuleToken *token, sd_device *dev,
> UdevEvent *event) {
>  *char* nbuf[UTIL_NAME_SIZE], *vbuf*[UTIL_NAME_SIZE]; // Here, vbuf is
> defined, however not initialized.
> *const char* *name, **value;*// Here, value is declared to be of
> type const char *, however, not initialized.
> ...
> ... // some code
> ...
> switch (token->attr_subst_type) {   // *Event 1* : This evaluates to
> SUBST_TYPE_PLAIN
> ...
> case *SUBST_TYPE_PLAIN*:   if (sd_device_get_sysattr_value(dev, name,
> ) < 0)   // *Event 2* :The if condition evaluates to false.
>  return false;
>  break;
> ...// some code
> ...
> }
> 
> if (token->attr_match_remove_trailing_whitespace) {  // *Event
> 4*: If condition evaluates to true
> if (value != vbuf) {  //  *Event 5* : vbuf and value
> are both declared but not initialized. Comparison is done without
> initializing "vbuf" and "value".
> strscpy(vbuf, sizeof(vbuf), value);
> value = vbuf;
> } // End of if.
> 
> delete_trailing_chars(vbuf, NULL); // *Event 6*:
> trying to delete trailing chars from "vbuf" which is not initialzed. ??
> } // End of outer if.
> ... // some code
> } /End of function : *token_match_attr()*
> 
> Below are my queries :
> 1. *Event 5 *above, we are comparing two resources ("value" and "vbuf")
> even before initializing them.
> Are we doing this comparision to do decision making based on whether
> the pointer type variable "value" is pointing to "vbuf" or not.
> *Query*: Kindly confirm whether my understanding is correct.
> 
> 2. *Event 6* above, delete_trailing_chars(vbuf, NULL) is called outside  *if
> (value != vbuf).*
> This implies there may occur a situation where:
>   step 1 ) *if (value != vbuf) *condition fails  --> step 2 )
> *vbuf* is not initialzed inside the *if(value != vbuf)  *--> step 3 )
> delete_trailing_chars(*vbuf*, NULL).
> Here, delete_trailing_chars() called for "*vbuf*" which is not necessarily
> initiazlied.
> *Query*: Kindly let me know if my understanding is correct or I am missing
> something.
> 
> Thanks,
> Amit




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


[systemd-devel] Initialization of "vbuf" in function "token_match_attr"

2020-09-08 Thread Amit anand
Hi systemd-devel team,

I am trying to understand where "vbuf" is initialized in function
"token_match_attr()" in file udev-rules.c

Below code snippet :
static bool* token_match_attr*(UdevRuleToken *token, sd_device *dev,
UdevEvent *event) {
 *char* nbuf[UTIL_NAME_SIZE], *vbuf*[UTIL_NAME_SIZE]; // Here, vbuf is
defined, however not initialized.
*const char* *name, **value;*// Here, value is declared to be of
type const char *, however, not initialized.
...
... // some code
...
switch (token->attr_subst_type) {   // *Event 1* : This evaluates to
SUBST_TYPE_PLAIN
...
case *SUBST_TYPE_PLAIN*:   if (sd_device_get_sysattr_value(dev, name,
) < 0)   // *Event 2* :The if condition evaluates to false.
 return false;
 break;
...// some code
...
}

if (token->attr_match_remove_trailing_whitespace) {  // *Event
4*: If condition evaluates to true
if (value != vbuf) {  //  *Event 5* : vbuf and value
are both declared but not initialized. Comparison is done without
initializing "vbuf" and "value".
strscpy(vbuf, sizeof(vbuf), value);
value = vbuf;
} // End of if.

delete_trailing_chars(vbuf, NULL); // *Event 6*:
trying to delete trailing chars from "vbuf" which is not initialzed. ??
} // End of outer if.
... // some code
} /End of function : *token_match_attr()*

Below are my queries :
1. *Event 5 *above, we are comparing two resources ("value" and "vbuf")
even before initializing them.
Are we doing this comparision to do decision making based on whether
the pointer type variable "value" is pointing to "vbuf" or not.
*Query*: Kindly confirm whether my understanding is correct.

2. *Event 6* above, delete_trailing_chars(vbuf, NULL) is called outside  *if
(value != vbuf).*
This implies there may occur a situation where:
  step 1 ) *if (value != vbuf) *condition fails  --> step 2 )
*vbuf* is not initialzed inside the *if(value != vbuf)  *--> step 3 )
delete_trailing_chars(*vbuf*, NULL).
Here, delete_trailing_chars() called for "*vbuf*" which is not necessarily
initiazlied.
*Query*: Kindly let me know if my understanding is correct or I am missing
something.

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


Re: [systemd-devel] Journal message timestamps

2020-09-08 Thread Kevin P. Fleming
On Tue, Sep 8, 2020 at 7:12 AM Reindl Harald  wrote:

> your playground is in
> /etc/systemd/system/fake-hwclock.service.d/myoverrides.conf
>
> and yes that is important so that you don#t have to redo your changes
> after each and every update and way better than cloning the whole
> unit-file in /etc/systemd/system/ so that reasonable upstream changes
> get applied in teh future
>
> -
>
> /etc/systemd/system/fake-hwclock.service.d/myoverrides.conf:
>
> [Unit]
> Before=systemd-journald.service

... and this is most easily done by using 'systemctl edit
fake-hwclock.service', which will create the file in the proper
location so you don't have to (and will handily cause a daemon reload
as well).
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Journal message timestamps

2020-09-08 Thread Reindl Harald



Am 08.09.20 um 13:06 schrieb Mark Corbin:
> Change /lib/systemd/system/fake-hwclock.service to add
> 'systemd-journald.service' to the end of the 'Before' line

this is *system* area and the admin has no business to touch anything
there as well as packages have no business to touch admin area in
/etc/systemd/system

your playground is in
/etc/systemd/system/fake-hwclock.service.d/myoverrides.conf

and yes that is important so that you don#t have to redo your changes
after each and every update and way better than cloning the whole
unit-file in /etc/systemd/system/ so that reasonable upstream changes
get applied in teh future

-

/etc/systemd/system/fake-hwclock.service.d/myoverrides.conf:

[Unit]
Before=systemd-journald.service
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Journal message timestamps

2020-09-08 Thread Mark Corbin




On 04/09/2020 22:02, Dave Howorth wrote:

On Fri, 4 Sep 2020 17:59:02 +0200
Lennart Poettering  wrote:

On Do, 27.08.20 11:33, Mark Corbin (m...@dibsco.co.uk) wrote:


Hello

I am working on time synchronisation issues at boot for systems
without an RTC (using balenaOS on a Raspberry Pi 3) and have some
questions about how journald assigns timestamps to log messages.

When I boot my system and look at the journal I see an initial
date/time for kernel messages, e.g. '1 June 2020 10:00:00' followed
by messages with the 'correct' date/time once the system time has
been set from another source, e.g. build time, NTP, etc. This means
that over several reboots I have lots of sets of log messages from
1 June 2020 which understandably confuses the 'journalctl
--list-boots' command. I found an issue that describes the problem
here https://github.com/systemd/systemd/issues/662 and had assumed
that there wasn't anything I could do about this.

However, when running some tests on a board with Raspberry Pi OS I
found that it didn't suffer from the same problem. RPI OS uses a
'fake-hwclock' service to restore the previous boot time from a
file and this time gets applied to all messages in the journal
prior to this point. I added the 'fake-hwclock' service to my
system which resulted in the timestamps being correct the majority
of the time, but I was still seeing some boots where the initial
messages were showing '1 June 2020'. I eventually tracked the
intermittent behaviour down to whether the 'fake-hwclock' time
setting occurred in the same system log file as the initial kernel
boot messages. On my RPI OS board the runtime journal was set to
8MB, so the date/time setting always occurred in the first journal
file. On my system the runtime journal was set to 4MB, so the
date/time setting was sometimes happening in the second journal
file leaving the messages in the first file with a date of '1 June
2020'.

So my questions are...

It seems that journald is using the date/time from the
'fake-hwclock' service to update the timestamps of earlier log
messages within the same file. Is this correct?


No. We do not retroactively change written out records.

However, when comparing log entries we prefer the record sequence
number if two records come from the same system. And if that doesn't
work, then we prefer monotonic clocks if two records cme from the same
boot. Wallclock is only used for comparing two records if they are
from different boots altogether.


What would be the best technique for ensuring that my journal logs
always display the 'best' time for log messages (either
'fake-hwclock' or NTP)? Do I always have to ensure that the journal
is large enough to capture my initial time setting event in the
first file?


There's no nice answer for that. We do not patch written out journal
records once they are written. They are considered immutable. This
means, from the journal's PoV if you generated a bunch of records in
the initrd or early boot (i.e. before /var/log/journal is available)
and you have no usable wallclock time, and you power cycle 10 times
in a row, then we have no indication about which of the 10 series of
recrods came in which order before the others.

To fix that we'd have to keep a separate log of boot ids or so
somewhere, which we could use as auxiliary source of truth if all we
have are bootids+monotonic time which came first by comparing boot
ids. But that would still not be perfect since we could write that out
only late (i.e. after /var becomes writable), so the order before that
could not be reconstructed either if the system doesn't get that far.

Also see:

https://github.com/systemd/systemd/issues/662


Any general details about how journald applies timestamps would
also be greatly appreciated.


(btw, systemd-timesyncd does what fake-hwclock does automatically, and
also does SNTP. it should be fine for most usecases, no need to resort
to fake-hwclock)

Lennart


This is a serious problem for anybody running a raspberry pi (i.e.
many, many thousands of people.) I suggest buying one for yourself and
actually experiencing the issues to understand what the problem is and
why people would like to see a solution.

I'll send you the dollars if that's really a problem.


Hello Dave

If you are able to do some testing on the RPI perhaps you could try my 
suggestion of always starting fake-hwclock before journald.


Change /lib/systemd/system/fake-hwclock.service to add 
'systemd-journald.service' to the end of the 'Before' line.


Let me know if this works for you.

Regards

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


Re: [systemd-devel] Antw: [EXT] Journal message timestamps

2020-09-08 Thread Mark Corbin



On 04/09/2020 17:19, Lennart Poettering wrote:

On Fr, 28.08.20 14:34, Mark Corbin (m...@dibsco.co.uk) wrote:


For example, when /run/log/journal/d197a2e910964a7f9a0de6462d0d7c62/
contains just 'system.journal' which has all log messages from:

'kernel: Booting Linux on physical CPU 0x0'
up to and including:
'fake-hwclock[827]: Fri Aug 28 12:12:08 UTC 2020'

then all messages displayed by journalctl are time stamped starting from
'Fri Aug 28 12:12:08' onwards. This is good - no problem.


So, as mentioned, we do not rewrite entries once written to disk and
they carry the original timestamp when they were gnerated, and if
that's off it's off. We will not "correct" something that was the
truth early on if we later figure out it wasn't actually true.

I think what you migh be seeing is the fact that we early on flush
kernel msgs into the journal, and since kernel msgs carry no elaborate
timestamps we generate them when we flush that. So maybe that flushing
happens after the fake rtc thing?



After more testing I think that you are right about this. If 
fake-hwclock manages to set the time before journald starts then the 
timestamps are all correct.


At the moment fake-hwclock doesn't have a dependency to start before 
journald on the RPI, so sometimes it does and sometimes it doesn't. I 
see that there is a call to clock_gettime in journald, so I guess that 
we are okay as long as fake-hwclock has set the time before this call.


Testing on both an RPI3 and RPI4 shows that the journal log timestamps 
fail intermittently (maybe once every 10 boots) with some messages 
displaying a date of Feb 14 2019 (for the Raspberry Pi OS Buster 
release). If I add an extra dependency to fake-hwclock.service, so that:


Before=sysinit.target systemd-fsck-root.service

becomes:

Before=sysinit.target systemd-fsck-root.service systemd-journald.service

Then the dates are always correct - I've been running fairly continuous 
reboots over the last day and it hasn't failed yet.


If you think that this dependency change makes sense, then I think it 
would be worth submitting an update to Debian/Raspberry Pi Os.


Regards

Mark




Lennart

--
Lennart Poettering, Berlin


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


Re: [systemd-devel] Q: Start a unit n minutes after a successful boot

2020-09-08 Thread Reindl Harald



Am 08.09.20 um 09:21 schrieb Ulrich Windl:
> Configuring a new system with non-redundant system disk I'm wondering: How 
> could I start an automatic backup job that is triggered n minutes after the 
> system started

* create a own target
* order it after multi-user.target
* put a service jn there which sleeps
* after the sleep or by a service ordered after that one
  do whatever you want to do

-

that below is something similar to not break existing connections by
reboot the gateway by disable nf_conntrack_tcp_loose at boot but do it
90 seconds later, in that cae no own target needed

[root@firewall:~]$  cat /etc/systemd/system/network-up-post.service
[Unit]
Description=Network Invalid-Detection
After=network-up.service
Requires=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutStartSec=90
ExecStart=/usr/bin/sleep 30
ExecStart=/usr/sbin/sysctl -q -e -w net.netfilter.nf_conntrack_tcp_loose=0

[Install]
WantedBy=multi-user.target
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Antw: [EXT] Re: Q: Start a unit n minutes after a successful boot

2020-09-08 Thread Ulrich Windl
>>> Tomasz Torcz  schrieb am 08.09.2020 um 09:58 in
Nachricht
<20200908075833.ga46...@mother.pipebreaker.pl>:
> On Tue, Sep 08, 2020 at 09:21:02AM +0200, Ulrich Windl wrote:
>> Hi!
>> 
>> Configuring a new system with non‑redundant system disk I'm wondering:
>> How could I start an automatic backup job that is triggered n minutes
>> after the system started successfully (to avoid backing up broken
>> configurations)?
> 
>   Timer with "OnBootSec=n minutes" is exactly what you want, right? 

Hi!

Is every boot a successful boot? Will (e.g.) default.target be reached even if
some service failed? If not, that is what I had in mind:
Start a unit n minutes after default.target was reached "sucessfully".

> 
> For judging if boot was successfull there are different approaches.
> On my Fedora I see user unit with timer activating after 2 minutes. 
> If user session lasted for that long, then
> ExecStart=/usr/sbin/grub2‑set‑bootflag boot_success
> is invoked. There were some discussion on this mailinglist how to
> improve detection and marking of good boot..

Assuming a good boot is a boot that lasts at least 2 minutes is silently
assuming that some human will reboot before if the boot was not sucessful?

Regards,
Ulrich

> 
> ‑‑ 
> Tomasz TorczOnce you've read the dictionary,
> to...@pipebreaker.plevery other book is just a remix.
> ___
> systemd‑devel mailing list
> systemd‑de...@lists.freedesktop.org 
> https://lists.freedesktop.org/mailman/listinfo/systemd‑devel 



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


Re: [systemd-devel] Q: Start a unit n minutes after a successful boot

2020-09-08 Thread Tomasz Torcz
On Tue, Sep 08, 2020 at 09:21:02AM +0200, Ulrich Windl wrote:
> Hi!
> 
> Configuring a new system with non-redundant system disk I'm wondering:
> How could I start an automatic backup job that is triggered n minutes
> after the system started successfully (to avoid backing up broken
> configurations)?

  Timer with "OnBootSec=n minutes" is exactly what you want, right? 

For judging if boot was successfull there are different approaches.
On my Fedora I see user unit with timer activating after 2 minutes. 
If user session lasted for that long, then
ExecStart=/usr/sbin/grub2-set-bootflag boot_success
is invoked. There were some discussion on this mailinglist how to
improve detection and marking of good boot..

-- 
Tomasz TorczOnce you've read the dictionary,
to...@pipebreaker.plevery other book is just a remix.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Q: Start a unit n minutes after a successful boot

2020-09-08 Thread Ulrich Windl
Hi!

Configuring a new system with non-redundant system disk I'm wondering: How 
could I start an automatic backup job that is triggered n minutes after the 
system started successfully (to avoid backing up broken configurations)?

Regards,
Ulrich



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


Re: [systemd-devel] Logind: how to access a device when you're not the session controller

2020-09-08 Thread Pekka Paalanen
On Mon, 7 Sep 2020 17:53:46 +0200
Lennart Poettering  wrote:

> On Mo, 07.09.20 11:47, Pekka Paalanen (ppaala...@gmail.com) wrote:
> 
> > > I am not aware of any.
> > >  
> > > > Any suggestions on what might work?  
> > >
> > > Other than patching logind with some new concept, no suggestion. Or
> > > simply bypassing logind and opening the devices directly with root
> > > privs? or test this in virtualization?  
> >
> > Thanks for the reply!
> >
> > That's a little inconvenient. I was hoping there might be a way
> > somehow, perhaps even create a new session and become its controller
> > without elevated privileges if the the seat in question is not "in
> > use". I could configure the extra DRM device into a non-default seat,
> > then try taking over that seat.  
> 
> You could open a new PAM session with "systemd-run -p PAMName=", and
> configure the seat for it via the XDG_SEAT env var. pam_systemd picks
> up the seat to use via XDG_SEAT env var.
> 
> (but it will require privs to run systemd-run)

Thanks, I'll keep that in mind. Going through logind will exercise the
logind-only code in Weston, and sometimes that is good to test. OTOH, I
can VT-switch to an unused tty and run Weston like normal. It's all
about convenience, particularly with 'git rebase -i --exec' to run
tests every commit.

> > Is that really not possible without some kind of elevated privileges my
> > normal desktop user doesn't usually have? Could it be allowed via
> > polkit configuration or something?
> >
> > Or maybe I indeed need to forget about logind and open the DRM device
> > as a normal user. After all, the first one to open a DRM device should
> > automatically gain DRM master status, and there have been recent kernel
> > patches to even allow dropping and re-gaining DRM master status without
> > being root/CAP_SYS_ADMIN IIUC. That won't help with input devices if I
> > wanted to test anything interactive... but maybe I could allow some
> > dedicated input devices to be opened by my normal user and make sure I
> > don't use those for my desktop.
> >
> > Right, maybe I can hack it up after forgetting about logind. Put all
> > those devices into a non-default seat, override their file permissions,
> > and assume they are untrusted (can be eavesdropped).  
> 
> Note that I myself never worked on a wayland compositor or suchlike, I
> have no experience with your perspective on these things: we look at
> this from the other side...

Appreciated. My use cases are all about developer testing, so they may
be fine as hacks. There are more use cases:
https://gitlab.freedesktop.org/wayland/weston/-/issues/132
https://gitlab.freedesktop.org/wayland/weston/-/issues/401
https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/438

Starting Weston via ssh is something developers use for testing on
embedded boards. Sounds like starting Weston in a container is also a
new developer use case. There exists curiosity towards CONFIG_VT=n
systems too.

This is for your information just in case you or someone might find it
interesting. If not, no worries.


Thanks,
pq


pgpMbczLgPWmA.pgp
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Alias use in socket file

2020-09-08 Thread Belisko Marek
Hi,

I'm using yocto build systemd and I'm using openssh server which
create sshd.socket + sshd@.service files. With socket I can control if
ssh is enabled / disabled. I have an application which expects to
check statu of ssh.service. I tried to add Alias=ssh.service to
sshd.socket file and tried systemd enable sshd.socket but systemd
cannot see ssh.service. Is there some other way to create a link to an
existing socket file? Thanks

BR,

marek

-- 
as simple and primitive as possible
-
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel