Gleydson Soares wrote:
> > what about just printing "doas: "?
> 
> I prefer not hardcoded string, although I've committed as you pointed out,

getprogname() doesn't seem any more portable than __progname, which is the
classic means of doing this. It's useful in cases where a program may have
more than one name, or be called via alias, or what have you. As evidenced by
the fact that a million programs use it. But...

Upon some reflection (some time ago, but not too long), I came to the
conclusion that this was an example of a best practice being over practiced
without regard to the rationale that recommends its use. Some of these strings
will never change. There is no gain in making them "portable" or "reusable".

(The man page for getprogname even happens to comment that setuid programs,
which includes doas, must be extra careful because they do not control the
string's contents. In your diff, it was safe, but a trivial modification that
attempted to build a larger string would have a vulnerability. We avoid such
mistakes in part by not doing potentially dangerous things even when safe.)

Reply via email to