chiark / gitweb /
tree-wide: rename config_parse_many to …_nulstr
[elogind.git] / src / shared / conf-parser.c
1 /***
2   This file is part of systemd.
3
4   Copyright 2010 Lennart Poettering
5
6   systemd is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License as published by
8   the Free Software Foundation; either version 2.1 of the License, or
9   (at your option) any later version.
10
11   systemd is distributed in the hope that it will be useful, but
12   WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   Lesser General Public License for more details.
15
16   You should have received a copy of the GNU Lesser General Public License
17   along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20 #include <errno.h>
21 #include <limits.h>
22 #include <stdint.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <sys/types.h>
27
28 #include "alloc-util.h"
29 #include "conf-files.h"
30 #include "conf-parser.h"
31 #include "extract-word.h"
32 #include "fd-util.h"
33 #include "fs-util.h"
34 #include "log.h"
35 #include "macro.h"
36 #include "parse-util.h"
37 #include "path-util.h"
38 #include "process-util.h"
39 #include "signal-util.h"
40 #include "string-util.h"
41 #include "strv.h"
42 #include "syslog-util.h"
43 #include "time-util.h"
44 #include "utf8.h"
45
46 int config_item_table_lookup(
47                 const void *table,
48                 const char *section,
49                 const char *lvalue,
50                 ConfigParserCallback *func,
51                 int *ltype,
52                 void **data,
53                 void *userdata) {
54
55         const ConfigTableItem *t;
56
57         assert(table);
58         assert(lvalue);
59         assert(func);
60         assert(ltype);
61         assert(data);
62
63         for (t = table; t->lvalue; t++) {
64
65                 if (!streq(lvalue, t->lvalue))
66                         continue;
67
68                 if (!streq_ptr(section, t->section))
69                         continue;
70
71                 *func = t->parse;
72                 *ltype = t->ltype;
73                 *data = t->data;
74                 return 1;
75         }
76
77         return 0;
78 }
79
80 int config_item_perf_lookup(
81                 const void *table,
82                 const char *section,
83                 const char *lvalue,
84                 ConfigParserCallback *func,
85                 int *ltype,
86                 void **data,
87                 void *userdata) {
88
89         ConfigPerfItemLookup lookup = (ConfigPerfItemLookup) table;
90         const ConfigPerfItem *p;
91
92         assert(table);
93         assert(lvalue);
94         assert(func);
95         assert(ltype);
96         assert(data);
97
98         if (!section)
99                 p = lookup(lvalue, strlen(lvalue));
100         else {
101                 char *key;
102
103                 key = strjoin(section, ".", lvalue, NULL);
104                 if (!key)
105                         return -ENOMEM;
106
107                 p = lookup(key, strlen(key));
108                 free(key);
109         }
110
111         if (!p)
112                 return 0;
113
114         *func = p->parse;
115         *ltype = p->ltype;
116         *data = (uint8_t*) userdata + p->offset;
117         return 1;
118 }
119
120 /* Run the user supplied parser for an assignment */
121 static int next_assignment(const char *unit,
122                            const char *filename,
123                            unsigned line,
124                            ConfigItemLookup lookup,
125                            const void *table,
126                            const char *section,
127                            unsigned section_line,
128                            const char *lvalue,
129                            const char *rvalue,
130                            bool relaxed,
131                            void *userdata) {
132
133         ConfigParserCallback func = NULL;
134         int ltype = 0;
135         void *data = NULL;
136         int r;
137
138         assert(filename);
139         assert(line > 0);
140         assert(lookup);
141         assert(lvalue);
142         assert(rvalue);
143
144         r = lookup(table, section, lvalue, &func, &ltype, &data, userdata);
145         if (r < 0)
146                 return r;
147
148         if (r > 0) {
149                 if (func)
150                         return func(unit, filename, line, section, section_line,
151                                     lvalue, ltype, rvalue, data, userdata);
152
153                 return 0;
154         }
155
156         /* Warn about unknown non-extension fields. */
157         if (!relaxed && !startswith(lvalue, "X-"))
158                 log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown lvalue '%s' in section '%s'", lvalue, section);
159
160         return 0;
161 }
162
163 /* Parse a variable assignment line */
164 static int parse_line(const char* unit,
165                       const char *filename,
166                       unsigned line,
167                       const char *sections,
168                       ConfigItemLookup lookup,
169                       const void *table,
170                       bool relaxed,
171                       bool allow_include,
172                       char **section,
173                       unsigned *section_line,
174                       bool *section_ignored,
175                       char *l,
176                       void *userdata) {
177
178         char *e;
179
180         assert(filename);
181         assert(line > 0);
182         assert(lookup);
183         assert(l);
184
185         l = strstrip(l);
186
187         if (!*l)
188                 return 0;
189
190         if (strchr(COMMENTS "\n", *l))
191                 return 0;
192
193         if (startswith(l, ".include ")) {
194                 _cleanup_free_ char *fn = NULL;
195
196                 /* .includes are a bad idea, we only support them here
197                  * for historical reasons. They create cyclic include
198                  * problems and make it difficult to detect
199                  * configuration file changes with an easy
200                  * stat(). Better approaches, such as .d/ drop-in
201                  * snippets exist.
202                  *
203                  * Support for them should be eventually removed. */
204
205                 if (!allow_include) {
206                         log_syntax(unit, LOG_ERR, filename, line, 0, ".include not allowed here. Ignoring.");
207                         return 0;
208                 }
209
210                 fn = file_in_same_dir(filename, strstrip(l+9));
211                 if (!fn)
212                         return -ENOMEM;
213
214                 return config_parse(unit, fn, NULL, sections, lookup, table, relaxed, false, false, userdata);
215         }
216
217         if (*l == '[') {
218                 size_t k;
219                 char *n;
220
221                 k = strlen(l);
222                 assert(k > 0);
223
224                 if (l[k-1] != ']') {
225                         log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid section header '%s'", l);
226                         return -EBADMSG;
227                 }
228
229                 n = strndup(l+1, k-2);
230                 if (!n)
231                         return -ENOMEM;
232
233                 if (sections && !nulstr_contains(sections, n)) {
234
235                         if (!relaxed && !startswith(n, "X-"))
236                                 log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown section '%s'. Ignoring.", n);
237
238                         free(n);
239                         *section = mfree(*section);
240                         *section_line = 0;
241                         *section_ignored = true;
242                 } else {
243                         free(*section);
244                         *section = n;
245                         *section_line = line;
246                         *section_ignored = false;
247                 }
248
249                 return 0;
250         }
251
252         if (sections && !*section) {
253
254                 if (!relaxed && !*section_ignored)
255                         log_syntax(unit, LOG_WARNING, filename, line, 0, "Assignment outside of section. Ignoring.");
256
257                 return 0;
258         }
259
260         e = strchr(l, '=');
261         if (!e) {
262                 log_syntax(unit, LOG_WARNING, filename, line, 0, "Missing '='.");
263                 return -EINVAL;
264         }
265
266         *e = 0;
267         e++;
268
269         return next_assignment(unit,
270                                filename,
271                                line,
272                                lookup,
273                                table,
274                                *section,
275                                *section_line,
276                                strstrip(l),
277                                strstrip(e),
278                                relaxed,
279                                userdata);
280 }
281
282 /* Go through the file and parse each line */
283 int config_parse(const char *unit,
284                  const char *filename,
285                  FILE *f,
286                  const char *sections,
287                  ConfigItemLookup lookup,
288                  const void *table,
289                  bool relaxed,
290                  bool allow_include,
291                  bool warn,
292                  void *userdata) {
293
294         _cleanup_free_ char *section = NULL, *continuation = NULL;
295         _cleanup_fclose_ FILE *ours = NULL;
296         unsigned line = 0, section_line = 0;
297         bool section_ignored = false, allow_bom = true;
298         int r;
299
300         assert(filename);
301         assert(lookup);
302
303         if (!f) {
304                 f = ours = fopen(filename, "re");
305                 if (!f) {
306                         /* Only log on request, except for ENOENT,
307                          * since we return 0 to the caller. */
308                         if (warn || errno == ENOENT)
309                                 log_full(errno == ENOENT ? LOG_DEBUG : LOG_ERR,
310                                          "Failed to open configuration file '%s': %m", filename);
311                         return errno == ENOENT ? 0 : -errno;
312                 }
313         }
314
315         fd_warn_permissions(filename, fileno(f));
316
317         for (;;) {
318                 char buf[LINE_MAX], *l, *p, *c = NULL, *e;
319                 bool escaped = false;
320
321                 if (!fgets(buf, sizeof buf, f)) {
322                         if (feof(f))
323                                 break;
324
325                         return log_error_errno(errno, "Failed to read configuration file '%s': %m", filename);
326                 }
327
328                 l = buf;
329                 if (allow_bom && startswith(l, UTF8_BYTE_ORDER_MARK))
330                         l += strlen(UTF8_BYTE_ORDER_MARK);
331                 allow_bom = false;
332
333                 truncate_nl(l);
334
335                 if (continuation) {
336                         c = strappend(continuation, l);
337                         if (!c) {
338                                 if (warn)
339                                         log_oom();
340                                 return -ENOMEM;
341                         }
342
343                         continuation = mfree(continuation);
344                         p = c;
345                 } else
346                         p = l;
347
348                 for (e = p; *e; e++) {
349                         if (escaped)
350                                 escaped = false;
351                         else if (*e == '\\')
352                                 escaped = true;
353                 }
354
355                 if (escaped) {
356                         *(e-1) = ' ';
357
358                         if (c)
359                                 continuation = c;
360                         else {
361                                 continuation = strdup(l);
362                                 if (!continuation) {
363                                         if (warn)
364                                                 log_oom();
365                                         return -ENOMEM;
366                                 }
367                         }
368
369                         continue;
370                 }
371
372                 r = parse_line(unit,
373                                filename,
374                                ++line,
375                                sections,
376                                lookup,
377                                table,
378                                relaxed,
379                                allow_include,
380                                &section,
381                                &section_line,
382                                &section_ignored,
383                                p,
384                                userdata);
385                 free(c);
386
387                 if (r < 0) {
388                         if (warn)
389                                 log_warning_errno(r, "Failed to parse file '%s': %m",
390                                                   filename);
391                         return r;
392                 }
393         }
394
395         return 0;
396 }
397
398 /* Parse each config file in the specified directories. */
399 int config_parse_many_nulstr(
400                 const char *conf_file,
401                 const char *conf_file_dirs,
402                 const char *sections,
403                 ConfigItemLookup lookup,
404                 const void *table,
405                 bool relaxed,
406                 void *userdata) {
407
408         _cleanup_strv_free_ char **files = NULL;
409         char **fn;
410         int r;
411
412         r = conf_files_list_nulstr(&files, ".conf", NULL, conf_file_dirs);
413         if (r < 0)
414                 return r;
415
416         if (conf_file) {
417                 r = config_parse(NULL, conf_file, NULL, sections, lookup, table, relaxed, false, true, userdata);
418                 if (r < 0)
419                         return r;
420         }
421
422         STRV_FOREACH(fn, files) {
423                 r = config_parse(NULL, *fn, NULL, sections, lookup, table, relaxed, false, true, userdata);
424                 if (r < 0)
425                         return r;
426         }
427
428         return 0;
429 }
430
431 #define DEFINE_PARSER(type, vartype, conv_func)                         \
432         int config_parse_##type(                                        \
433                         const char *unit,                               \
434                         const char *filename,                           \
435                         unsigned line,                                  \
436                         const char *section,                            \
437                         unsigned section_line,                          \
438                         const char *lvalue,                             \
439                         int ltype,                                      \
440                         const char *rvalue,                             \
441                         void *data,                                     \
442                         void *userdata) {                               \
443                                                                         \
444                 vartype *i = data;                                      \
445                 int r;                                                  \
446                                                                         \
447                 assert(filename);                                       \
448                 assert(lvalue);                                         \
449                 assert(rvalue);                                         \
450                 assert(data);                                           \
451                                                                         \
452                 r = conv_func(rvalue, i);                               \
453                 if (r < 0)                                              \
454                         log_syntax(unit, LOG_ERR, filename, line, r,    \
455                                    "Failed to parse %s value, ignoring: %s", \
456                                    #type, rvalue);                      \
457                                                                         \
458                 return 0;                                               \
459         }                                                               \
460         struct __useless_struct_to_allow_trailing_semicolon__
461
462 DEFINE_PARSER(int, int, safe_atoi);
463 DEFINE_PARSER(long, long, safe_atoli);
464 DEFINE_PARSER(uint16, uint16_t, safe_atou16);
465 DEFINE_PARSER(uint32, uint32_t, safe_atou32);
466 DEFINE_PARSER(uint64, uint64_t, safe_atou64);
467 DEFINE_PARSER(unsigned, unsigned, safe_atou);
468 DEFINE_PARSER(double, double, safe_atod);
469 #if 0 /// UNNEEDED by elogind
470 DEFINE_PARSER(nsec, nsec_t, parse_nsec);
471 #endif // 0
472 DEFINE_PARSER(sec, usec_t, parse_sec);
473 DEFINE_PARSER(mode, mode_t, parse_mode);
474
475 int config_parse_iec_size(const char* unit,
476                             const char *filename,
477                             unsigned line,
478                             const char *section,
479                             unsigned section_line,
480                             const char *lvalue,
481                             int ltype,
482                             const char *rvalue,
483                             void *data,
484                             void *userdata) {
485
486         size_t *sz = data;
487         uint64_t v;
488         int r;
489
490         assert(filename);
491         assert(lvalue);
492         assert(rvalue);
493         assert(data);
494
495         r = parse_size(rvalue, 1024, &v);
496         if (r < 0 || (uint64_t) (size_t) v != v) {
497                 log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue);
498                 return 0;
499         }
500
501         *sz = (size_t) v;
502         return 0;
503 }
504
505 #if 0 /// UNNEEDED by elogind
506 int config_parse_si_size(const char* unit,
507                             const char *filename,
508                             unsigned line,
509                             const char *section,
510                             unsigned section_line,
511                             const char *lvalue,
512                             int ltype,
513                             const char *rvalue,
514                             void *data,
515                             void *userdata) {
516
517         size_t *sz = data;
518         uint64_t v;
519         int r;
520
521         assert(filename);
522         assert(lvalue);
523         assert(rvalue);
524         assert(data);
525
526         r = parse_size(rvalue, 1000, &v);
527         if (r < 0 || (uint64_t) (size_t) v != v) {
528                 log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue);
529                 return 0;
530         }
531
532         *sz = (size_t) v;
533         return 0;
534 }
535
536 int config_parse_iec_uint64(const char* unit,
537                            const char *filename,
538                            unsigned line,
539                            const char *section,
540                            unsigned section_line,
541                            const char *lvalue,
542                            int ltype,
543                            const char *rvalue,
544                            void *data,
545                            void *userdata) {
546
547         uint64_t *bytes = data;
548         int r;
549
550         assert(filename);
551         assert(lvalue);
552         assert(rvalue);
553         assert(data);
554
555         r = parse_size(rvalue, 1024, bytes);
556         if (r < 0)
557                 log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue);
558
559         return 0;
560 }
561 #endif // 0
562
563 int config_parse_bool(const char* unit,
564                       const char *filename,
565                       unsigned line,
566                       const char *section,
567                       unsigned section_line,
568                       const char *lvalue,
569                       int ltype,
570                       const char *rvalue,
571                       void *data,
572                       void *userdata) {
573
574         int k;
575         bool *b = data;
576
577         assert(filename);
578         assert(lvalue);
579         assert(rvalue);
580         assert(data);
581
582         k = parse_boolean(rvalue);
583         if (k < 0) {
584                 log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse boolean value, ignoring: %s", rvalue);
585                 return 0;
586         }
587
588         *b = !!k;
589         return 0;
590 }
591
592 #if 0 /// UNNEEDED by elogind
593 int config_parse_tristate(
594                 const char* unit,
595                 const char *filename,
596                 unsigned line,
597                 const char *section,
598                 unsigned section_line,
599                 const char *lvalue,
600                 int ltype,
601                 const char *rvalue,
602                 void *data,
603                 void *userdata) {
604
605         int k, *t = data;
606
607         assert(filename);
608         assert(lvalue);
609         assert(rvalue);
610         assert(data);
611
612         /* A tristate is pretty much a boolean, except that it can
613          * also take the special value -1, indicating "uninitialized",
614          * much like NULL is for a pointer type. */
615
616         k = parse_boolean(rvalue);
617         if (k < 0) {
618                 log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse boolean value, ignoring: %s", rvalue);
619                 return 0;
620         }
621
622         *t = !!k;
623         return 0;
624 }
625 #endif // 0
626
627 int config_parse_string(
628                 const char *unit,
629                 const char *filename,
630                 unsigned line,
631                 const char *section,
632                 unsigned section_line,
633                 const char *lvalue,
634                 int ltype,
635                 const char *rvalue,
636                 void *data,
637                 void *userdata) {
638
639         char **s = data, *n;
640
641         assert(filename);
642         assert(lvalue);
643         assert(rvalue);
644         assert(data);
645
646         if (!utf8_is_valid(rvalue)) {
647                 log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
648                 return 0;
649         }
650
651         if (isempty(rvalue))
652                 n = NULL;
653         else {
654                 n = strdup(rvalue);
655                 if (!n)
656                         return log_oom();
657         }
658
659         free(*s);
660         *s = n;
661
662         return 0;
663 }
664
665 int config_parse_path(
666                 const char *unit,
667                 const char *filename,
668                 unsigned line,
669                 const char *section,
670                 unsigned section_line,
671                 const char *lvalue,
672                 int ltype,
673                 const char *rvalue,
674                 void *data,
675                 void *userdata) {
676
677         char **s = data, *n;
678
679         assert(filename);
680         assert(lvalue);
681         assert(rvalue);
682         assert(data);
683
684         if (!utf8_is_valid(rvalue)) {
685                 log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
686                 return 0;
687         }
688
689         if (!path_is_absolute(rvalue)) {
690                 log_syntax(unit, LOG_ERR, filename, line, 0, "Not an absolute path, ignoring: %s", rvalue);
691                 return 0;
692         }
693
694         n = strdup(rvalue);
695         if (!n)
696                 return log_oom();
697
698         path_kill_slashes(n);
699
700         free(*s);
701         *s = n;
702
703         return 0;
704 }
705
706 int config_parse_strv(const char *unit,
707                       const char *filename,
708                       unsigned line,
709                       const char *section,
710                       unsigned section_line,
711                       const char *lvalue,
712                       int ltype,
713                       const char *rvalue,
714                       void *data,
715                       void *userdata) {
716
717         char ***sv = data;
718         int r;
719
720         assert(filename);
721         assert(lvalue);
722         assert(rvalue);
723         assert(data);
724
725         if (isempty(rvalue)) {
726                 char **empty;
727
728                 /* Empty assignment resets the list. As a special rule
729                  * we actually fill in a real empty array here rather
730                  * than NULL, since some code wants to know if
731                  * something was set at all... */
732                 empty = new0(char*, 1);
733                 if (!empty)
734                         return log_oom();
735
736                 strv_free(*sv);
737                 *sv = empty;
738
739                 return 0;
740         }
741
742         for (;;) {
743                 char *word = NULL;
744
745                 r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES|EXTRACT_RETAIN_ESCAPE);
746                 if (r == 0)
747                         break;
748                 if (r == -ENOMEM)
749                         return log_oom();
750                 if (r < 0) {
751                         log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
752                         break;
753                 }
754
755                 if (!utf8_is_valid(word)) {
756                         log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
757                         free(word);
758                         continue;
759                 }
760                 r = strv_consume(sv, word);
761                 if (r < 0)
762                         return log_oom();
763         }
764
765         return 0;
766 }
767
768 #if 0 /// UNNEEDED by elogind
769 int config_parse_log_facility(
770                 const char *unit,
771                 const char *filename,
772                 unsigned line,
773                 const char *section,
774                 unsigned section_line,
775                 const char *lvalue,
776                 int ltype,
777                 const char *rvalue,
778                 void *data,
779                 void *userdata) {
780
781
782         int *o = data, x;
783
784         assert(filename);
785         assert(lvalue);
786         assert(rvalue);
787         assert(data);
788
789         x = log_facility_unshifted_from_string(rvalue);
790         if (x < 0) {
791                 log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue);
792                 return 0;
793         }
794
795         *o = (x << 3) | LOG_PRI(*o);
796
797         return 0;
798 }
799 #endif // 0
800
801 int config_parse_log_level(
802                 const char *unit,
803                 const char *filename,
804                 unsigned line,
805                 const char *section,
806                 unsigned section_line,
807                 const char *lvalue,
808                 int ltype,
809                 const char *rvalue,
810                 void *data,
811                 void *userdata) {
812
813
814         int *o = data, x;
815
816         assert(filename);
817         assert(lvalue);
818         assert(rvalue);
819         assert(data);
820
821         x = log_level_from_string(rvalue);
822         if (x < 0) {
823                 log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue);
824                 return 0;
825         }
826
827         *o = (*o & LOG_FACMASK) | x;
828         return 0;
829 }
830
831 int config_parse_signal(
832                 const char *unit,
833                 const char *filename,
834                 unsigned line,
835                 const char *section,
836                 unsigned section_line,
837                 const char *lvalue,
838                 int ltype,
839                 const char *rvalue,
840                 void *data,
841                 void *userdata) {
842
843         int *sig = data, r;
844
845         assert(filename);
846         assert(lvalue);
847         assert(rvalue);
848         assert(sig);
849
850         r = signal_from_string_try_harder(rvalue);
851         if (r <= 0) {
852                 log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue);
853                 return 0;
854         }
855
856         *sig = r;
857         return 0;
858 }
859
860 #if 0 /// UNNEEDED by elogind
861 int config_parse_personality(
862                 const char *unit,
863                 const char *filename,
864                 unsigned line,
865                 const char *section,
866                 unsigned section_line,
867                 const char *lvalue,
868                 int ltype,
869                 const char *rvalue,
870                 void *data,
871                 void *userdata) {
872
873         unsigned long *personality = data, p;
874
875         assert(filename);
876         assert(lvalue);
877         assert(rvalue);
878         assert(personality);
879
880         p = personality_from_string(rvalue);
881         if (p == PERSONALITY_INVALID) {
882                 log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse personality, ignoring: %s", rvalue);
883                 return 0;
884         }
885
886         *personality = p;
887         return 0;
888 }
889
890 int config_parse_ifname(
891                 const char *unit,
892                 const char *filename,
893                 unsigned line,
894                 const char *section,
895                 unsigned section_line,
896                 const char *lvalue,
897                 int ltype,
898                 const char *rvalue,
899                 void *data,
900                 void *userdata) {
901
902         char **s = data;
903         int r;
904
905         assert(filename);
906         assert(lvalue);
907         assert(rvalue);
908         assert(data);
909
910         if (isempty(rvalue)) {
911                 *s = mfree(*s);
912                 return 0;
913         }
914
915         if (!ifname_valid(rvalue)) {
916                 log_syntax(unit, LOG_ERR, filename, line, 0, "Interface name is not valid or too long, ignoring assignment: %s", rvalue);
917                 return 0;
918         }
919
920         r = free_and_strdup(s, rvalue);
921         if (r < 0)
922                 return log_oom();
923
924         return 0;
925 }
926 #endif // 0