[systemd-devel] [PATCH] cryptsetup-generator: Add JobTimeoutSec=0 for all known crypt devices

Lennart Poettering lennart at poettering.net
Fri Mar 1 08:40:48 PST 2013


On Fri, 01.03.13 15:22, Lennart Poettering (lennart at poettering.net) wrote:

> 
> On Fri, 01.03.13 15:13, harald at redhat.com (harald at redhat.com) wrote:
> 
> > From: Harald Hoyer <harald at redhat.com>
> > 
> > put JobTimeoutSec=0 in <device-unit>.d/JobTimeoutSec0.conf files
> > 
> > This helps with grabbing a cup of coffee while booting and not have the
> > crypto password dialog timeout and systemd in a failed state.
> 
> I am not sure I like this too much, since fstab generally doesn't list
> things based on /dev/mapper, but via UUID= or suchlike, where this
> brings no benefit...

As discussed by phone: the I think this first part actually could go in,
it won't fix all problems, but at least those for folks which refer to
the crypt devices via /dev/mapper/ links.

Before merging this should probably be changed to use
write_one_line_file(), and the file name should probably be changed to
"50-job-timeout-sec.conf" or so...

The second part shouldn't go in, I think. Instead we should get you a
global configurable default timeout, via kernel cmdline and config file.

> 
> > ---
> >  src/cryptsetup/cryptsetup-generator.c | 62 +++++++++++++++++++++++++++++++++++
> >  1 file changed, 62 insertions(+)
> > 
> > diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
> > index 38a7cfa..55fc4b7 100644
> > --- a/src/cryptsetup/cryptsetup-generator.c
> > +++ b/src/cryptsetup/cryptsetup-generator.c
> > @@ -221,6 +221,68 @@ static int create_disk(
> >                  goto fail;
> >          }
> >  
> > +        if (!noauto && !nofail) {
> > +                free(p);
> > +                p = strjoin(arg_dest, "/dev-mapper-", e, ".device.d/JobTimeoutSec0.conf", NULL);
> > +                if (!p) {
> > +                        r = log_oom();
> > +                        goto fail;
> > +                }
> > +
> > +                mkdir_parents_label(p, 0755);
> > +
> > +                if (f)
> > +                        fclose(f);
> > +                f = fopen(p, "wxe");
> > +                if (!f) {
> > +                        r = -errno;
> > +                        log_error("Failed to create unit file %s: %m", p);
> > +                        goto fail;
> > +                }
> > +
> > +                fprintf(f,
> > +                        "# Automatically generated by systemd-cryptsetup-generator\n\n"
> > +                        "[Unit]\n"
> > +                        "JobTimeoutSec=0\n" /* the binary handles timeouts anyway */
> > +                        );
> > +                fflush(f);
> > +
> > +                if (ferror(f)) {
> > +                        r = -errno;
> > +                        log_error("Failed to write file %s: %m", p);
> > +                        goto fail;
> > +                }
> > +
> > +                free(p);
> > +                p = strjoin(arg_dest, "/", d, ".d/JobTimeoutSec0.conf", NULL);
> > +                if (!p) {
> > +                        r = log_oom();
> > +                        goto fail;
> > +                }
> > +
> > +                mkdir_parents_label(p, 0755);
> > +
> > +                f = fopen(p, "wxe");
> > +                if (!f) {
> > +                        r = -errno;
> > +                        log_error("Failed to create unit file %s: %m", p);
> > +                        goto fail;
> > +                }
> > +
> > +                fprintf(f,
> > +                        "# Automatically generated by systemd-cryptsetup-generator\n\n"
> > +                        "[Unit]\n"
> > +                        "JobTimeoutSec=0\n" /* the binary handles timeouts anyway */
> > +                        );
> > +                fflush(f);
> > +
> > +                if (ferror(f)) {
> > +                        r = -errno;
> > +                        log_error("Failed to write file %s: %m", p);
> > +                        goto fail;
> > +                }
> > +        }
> > +
> >          r = 0;
> >  
> >  fail:
> 
> 
> Lennart
> 


Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list