Index | Thread | Search

From:
Sebastien Marie <semarie@kapouay.eu.org>
Subject:
Re: login.conf.5: document "infinity" value in size type
To:
Evan Silberman <evan@jklol.net>, Evan Silberman <evan@jklol.net>
Cc:
tech@openbsd.org, landry@openbsd.org
Date:
Sat, 25 Jan 2025 08:59:11 +0100

Download raw body.

Thread
Evan Silberman <evan@jklol.net> writes:

> Evan Silberman <evan@jklol.net> wrote:
>> Sebastien Marie <semarie@kapouay.eu.org> wrote:
>> > Hi,
>> > 
>> > landry@ reported recently that login.conf(5) man page missed to document
>> > "infinity" value for fields like "datasize-cur".
>> > 
>> > After looking at code in lib/libc/gen/login_cap.c (specially
>> > login_getcapsize() and strtolimit() functions), valid "infinity" values
>> > are:
>> > - infinity
>> > - inf
>> > 
>> > The following diff adds a sentence to "size" argument type description,
>> > to mention the both keywords.
>> > 
>> > I reused the wording in getrlimit(2).
>> > 

>> This reads awkwardly. I'd rewrite the whole thing as:
>> 
>> .It size
>> A number which expresses a size limit, or
>> .Ql infinity
>> for no limit.
>> By default, the size is specified in bytes.
>> It may have a trailing
>> .Li b ,
>> .Li k ,
>> .Li m ,
>> .Li g
>> or
>> .Li t
>> to indicate that the value is in 512-byte blocks,
>> kilobytes, megabytes, gigabytes, or terabytes, respectively.
>
> Glancing at my (I think unmodified) login.conf and then at login_cap.c
> it seems that it's not only the "size" type that allows "infinity" as a
> value. See the definitions of login_getcaptime() and login_getcapnum().
> (Neither function allows "inf".) So the factoid about "infinity"
> may need to either be repeated or stated once with reference to
> the size, time, and number fields.

You are right. I only checked strtolimit() usage, and only
login_getcapsize() was using it.

login_getcaptime() and login_getcapnum() are also using "infinity"
keyword for no limit, but not "inf". So there is some inconsequently.

the following diff adds "inf" as alias for "infinity" for
login_getcaptime() and login_getcapnum() as it is more forward
compatible than removing "inf" from login_getcapsize().

it also adds documentation for "infinity" (but not for "inf", I am
unsure how to write it) for num, time and size argument type
description.

I removed Va usage in size for "number" as it isn't a variable name
(and others argument type doesn't use Va).

Thanks.
-- 
Sebastien Marie

diff --git a/lib/libc/gen/login_cap.c b/lib/libc/gen/login_cap.c
index 1460181b37..c0b6fc9f77 100644
--- a/lib/libc/gen/login_cap.c
+++ b/lib/libc/gen/login_cap.c
@@ -283,7 +283,7 @@
 
 	errno = 0;
 
-	if (strcasecmp(res, "infinity") == 0) {
+	if (strcasecmp(res, "infinity") == 0 || strcasecmp(res, "inf") == 0) {
 		free(res);
 		return (RLIM_INFINITY);
 	}
@@ -368,7 +368,7 @@
 
 	errno = 0;
 
-	if (strcasecmp(res, "infinity") == 0) {
+	if (strcasecmp(res, "infinity") == 0 || strcasecmp(res, "inf") == 0) {
 		free(res);
 		return (RLIM_INFINITY);
 	}
diff --git a/share/man/man5/login.conf.5 b/share/man/man5/login.conf.5
index 3d6d92a14c..b62b977aec 100644
--- a/share/man/man5/login.conf.5
+++ b/share/man/man5/login.conf.5
@@ -379,7 +379,9 @@
 A comma-separated list of values.
 .\"
 .It number
-A number.
+A number, or
+.Ql infinity
+for no limit.
 A leading
 .Li 0x
 implies the number is expressed in hexadecimal.
@@ -400,9 +402,9 @@
 A path name to program.
 .\"
 .It size
-A
-.Va number
-which expresses a size.
+A number which expresses a size, or
+.Ql infinity
+for no limit.
 By default, the size is specified in bytes.
 It may have a trailing
 .Li b ,
@@ -415,7 +417,9 @@
 kilobytes, megabytes, gigabytes, or terabytes, respectively.
 .\"
 .It time
-A time in seconds.
+A time in seconds, or
+.Ql infinity
+for no limit.
 A time may be expressed as a series of numbers which are added together.
 Each number may have a trailing character to represent time units:
 .Bl -tag -width xxx