From: Kyle Ackerman Subject: Re: got{,sys,web}d link-kits To: stsp@stsp.name Cc: gameoftrees@openbsd.org Date: Tue, 09 Jun 2026 19:33:33 -0600 Stefan Sperling writes: > On Mon, Jun 08, 2026 at 07:55:18PM -0600, Kyle Ackerman wrote: >> Below is a patch to add a flag to got{,sys,webd}d to simply print its >> version. My next diff will be to use this as a target for the new >> RELINK flag in `bsd.prog.mk`. This will enable link-kits to be >> generated with `make afterinstall` in each of the respecting directories >> of a got release (i.e., GOT_RELEASE=Yes). This should not affect >> anything, since nothing calls the afterinstall tagret. > > Fine with me. > > got, tog, gotadmin, gotsys, gotctl, and gotsysctl also accept the > --version long option. Should the daemons also accept --version? After skimming the source code, I think we only have long options for --verbose? Are there any plans to support more long options? I wouldn't be horribly against removing long options if the only reason we have them is for just that one option (with no intentions of having more). Anyways here is a diff with them (also updated man pages): diff /home/kyle/src/got path + /home/kyle/src/got commit - 096bbdd5c19f73da088ad751066c9f8b5a83c530 blob - 4b0ff341e0ac616da806e88be16688d8f58dc717 file + gotd/gotd.8 --- gotd/gotd.8 +++ gotd/gotd.8 @@ -72,6 +72,8 @@ will be used if it exists. .It Fl v Verbose mode. Verbosity increases if this option is used multiple times. +.It Fl V , -version +Display program version and exit immediately. .El .Sh FILES .Bl -tag -width Ds -compact commit - 096bbdd5c19f73da088ad751066c9f8b5a83c530 blob - 710cabca09101ba03c5106568a96a76da74015d0 file + gotd/gotd.c --- gotd/gotd.c +++ gotd/gotd.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "got_version.h" #include "got_error.h" @@ -3422,12 +3423,16 @@ main(int argc, char **argv) FILE *diff_f1 = NULL, *diff_f2 = NULL, *tmp_f1 = NULL, *tmp_f2 = NULL; int diff_fd1 = -1, diff_fd2 = -1, tmp_fd = -1; const char *errstr; - + static const struct option longopts[] = { + { "version", no_argument, NULL, 'V' }, + { NULL, 0, NULL, 0 } + }; + TAILQ_INIT(&procs); log_init(1, LOG_DAEMON); /* Log to stderr until daemonized. */ - while ((ch = getopt(argc, argv, "df:nP:s:T:vV")) != -1) { + while ((ch = getopt_long(argc, argv, "df:nP:s:T:vV", longopts, NULL)) != -1) { switch (ch) { case 'd': daemonize = 0; commit - 096bbdd5c19f73da088ad751066c9f8b5a83c530 blob - 9f9c1f2c4240b960a3b75ca0fdad174a8b9aab2e file + gotsysd/gotsysd.8 --- gotsysd/gotsysd.8 +++ gotsysd/gotsysd.8 @@ -94,6 +94,8 @@ Only check the configuration file for validity. .It Fl v Verbose mode. Verbosity increases if this option is used multiple times. +.It Fl V , -version +Display program version and exit immediately. .El .Sh FILES .Bl -tag -width Ds -compact commit - 096bbdd5c19f73da088ad751066c9f8b5a83c530 blob - 80f3d9899205a95228084df9d98014e02547103c file + gotsysd/gotsysd.c --- gotsysd/gotsysd.c +++ gotsysd/gotsysd.c @@ -1685,10 +1685,14 @@ main(int argc, char **argv) const char *errstr; char *commit_id_str = NULL; int ch, fd = -1, daemonize = 1, verbosity = 0, noaction = 0, version_flag = 0; + static const struct option longopts[] = { + { "version", no_argument, NULL, 'V' }, + { NULL, 0, NULL, 0 } + }; log_init(1, LOG_DAEMON); /* Log to stderr until daemonized. */ - while ((ch = getopt(argc, argv, "df:nT:vV")) != -1) { + while ((ch = getopt_long(argc, argv, "df:nT:vV", longopts, NULL)) != -1) { switch (ch) { case 'd': daemonize = 0; commit - 096bbdd5c19f73da088ad751066c9f8b5a83c530 blob - caa187ef6c305a2ecebdb16e1b2653b8c8845694 file + gotwebd/gotwebd.8 --- gotwebd/gotwebd.8 +++ gotwebd/gotwebd.8 @@ -57,6 +57,8 @@ Parse the configuration file, report errors if any, an .It Fl v Verbose mode. Verbosity increases if this option is used multiple times. +.It Fl V , -version +Display program version and exit immediately. .El .Pp Enabling commit - 096bbdd5c19f73da088ad751066c9f8b5a83c530 blob - 7fa2bfca9e54426683bbd8697cc6711357bf559c file + gotwebd/gotwebd.c --- gotwebd/gotwebd.c +++ gotwebd/gotwebd.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "got_version.h" #include "got_opentemp.h" @@ -916,6 +917,10 @@ main(int argc, char **argv) gid_t gotwebd_groups[NGROUPS_MAX]; gid_t www_gid; const char *argv0, *errstr; + static const struct option longopts[] = { + { "version", no_argument, NULL, 'V' }, + { NULL, 0, NULL, 0 } + }; if ((argv0 = argv[0]) == NULL) argv0 = "gotwebd"; @@ -928,7 +933,7 @@ main(int argc, char **argv) fatal("%s: calloc", __func__); config_init(env); - while ((ch = getopt(argc, argv, "A:C:D:dG:f:F:L:nS:vVW:")) != -1) { + while ((ch = getopt_long(argc, argv, "A:C:D:dG:f:F:L:nS:vVW:", longopts, NULL)) != -1) { switch (ch) { case 'A': proc_type = GOTWEBD_PROC_AUTH; > And it seems like gotwebctl only accepts -v, not --version. > It looks like to me gotwebctl does: (snippet below) int main(int argc, char *argv[]) { ... static const struct option longopts[] = { { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0 } }; const char *socket_path = GOTWEBD_CONTROL_SOCKET; setlocale(LC_CTYPE, ""); #ifndef PROFILE if (pledge("stdio rpath unix unveil", NULL) == -1) err(1, "pledge"); #endif while ((ch = getopt_long(argc, argv, "+hf:V", longopts, NULL)) != -1) { ... >> ----------------------------------------------- >> commit 096bbdd5c19f73da088ad751066c9f8b5a83c530 (link-kit) >> from: Kyle Ackerman >> date: Mon Jun 8 23:08:22 2026 UTC >> >> Add version flag (-V) to gotsysd >> >> diff 5d2011d41318bd291a0b0dd4241f52b8f84ef205 096bbdd5c19f73da088ad751066c9f8b5a83c530 >> commit - 5d2011d41318bd291a0b0dd4241f52b8f84ef205 >> commit + 096bbdd5c19f73da088ad751066c9f8b5a83c530 >> blob - 5f7ed278db7c6256c2c43f1ec3c299af2dd33cfd >> blob + 80f3d9899205a95228084df9d98014e02547103c >> --- gotsysd/gotsysd.c >> +++ gotsysd/gotsysd.c >> @@ -36,6 +36,7 @@ >> #include >> #include >> >> +#include "got_version.h" >> #include "got_error.h" >> #include "got_path.h" >> #include "got_object.h" >> @@ -1683,11 +1684,11 @@ main(int argc, char **argv) >> uid_t uid; >> const char *errstr; >> char *commit_id_str = NULL; >> - int ch, fd = -1, daemonize = 1, verbosity = 0, noaction = 0; >> + int ch, fd = -1, daemonize = 1, verbosity = 0, noaction = 0, version_flag = 0; >> >> log_init(1, LOG_DAEMON); /* Log to stderr until daemonized. */ >> >> - while ((ch = getopt(argc, argv, "df:nT:v")) != -1) { >> + while ((ch = getopt(argc, argv, "df:nT:vV")) != -1) { >> switch (ch) { >> case 'd': >> daemonize = 0; >> @@ -1723,6 +1724,9 @@ main(int argc, char **argv) >> if (verbosity < 3) >> verbosity++; >> break; >> + case 'V': >> + version_flag = 1; >> + break; >> default: >> usage(); >> } >> @@ -1737,6 +1741,11 @@ main(int argc, char **argv) >> commit_id_str = argv[0]; >> } else if (argc != 0) >> usage(); >> + >> + if (version_flag) { >> + got_version_print_str(); >> + return 0; >> + } >> >> if (geteuid() && (proc_id == GOTSYSD_PROC_GOTSYSD || >> proc_id == GOTSYSD_PROC_LISTEN || proc_id == GOTSYSD_PROC_PRIV)) >> >> ----------------------------------------------- >> commit 5d2011d41318bd291a0b0dd4241f52b8f84ef205 >> from: Kyle Ackerman >> date: Mon Jun 8 23:05:48 2026 UTC >> >> Add version flag (-V) to gotwebd >> >> diff b927ba2e520952ab93f10cbac289a1a0cc51c698 5d2011d41318bd291a0b0dd4241f52b8f84ef205 >> commit - b927ba2e520952ab93f10cbac289a1a0cc51c698 >> commit + 5d2011d41318bd291a0b0dd4241f52b8f84ef205 >> blob - 9b5f4c0c977df666c415adfe21cc989227c981ee >> blob + 7fa2bfca9e54426683bbd8697cc6711357bf559c >> --- gotwebd/gotwebd.c >> +++ gotwebd/gotwebd.c >> @@ -43,6 +43,7 @@ >> #include >> #include >> >> +#include "got_version.h" >> #include "got_opentemp.h" >> #include "got_reference.h" >> #include "got_object.h" >> @@ -907,7 +908,7 @@ main(int argc, char **argv) >> struct gotwebd *env; >> struct passwd *pw; >> int ch, i, gotwebd_ngroups = NGROUPS_MAX; >> - int no_action = 0; >> + int no_action = 0, version_flag = 0; >> int proc_type = GOTWEBD_PROC_PARENT; >> const char *conffile = GOTWEBD_CONF; >> const char *gotwebd_username = GOTWEBD_DEFAULT_USER; >> @@ -927,7 +928,7 @@ main(int argc, char **argv) >> fatal("%s: calloc", __func__); >> config_init(env); >> >> - while ((ch = getopt(argc, argv, "A:C:D:dG:f:F:L:nS:vW:")) != -1) { >> + while ((ch = getopt(argc, argv, "A:C:D:dG:f:F:L:nS:vVW:")) != -1) { >> switch (ch) { >> case 'A': >> proc_type = GOTWEBD_PROC_AUTH; >> @@ -978,6 +979,9 @@ main(int argc, char **argv) >> if (env->gotwebd_verbose < 3) >> env->gotwebd_verbose++; >> break; >> + case 'V': >> + version_flag = 1; >> + break; >> default: >> usage(); >> } >> @@ -987,6 +991,10 @@ main(int argc, char **argv) >> if (argc > 0) >> usage(); >> >> + if (version_flag) { >> + got_version_print_str(); >> + return 0; >> + } >> gotwebd_env = env; >> env->gotwebd_conffile = conffile; >> >> >> ----------------------------------------------- >> commit b927ba2e520952ab93f10cbac289a1a0cc51c698 >> from: Kyle Ackerman >> date: Mon Jun 8 23:05:48 2026 UTC >> >> Add version flag (-V) to gotd >> >> diff 6491565c93d1768e5efefb8aded89b098a3d34f2 b927ba2e520952ab93f10cbac289a1a0cc51c698 >> commit - 6491565c93d1768e5efefb8aded89b098a3d34f2 >> commit + b927ba2e520952ab93f10cbac289a1a0cc51c698 >> blob - e4775c44eadfd1bc72e15c5b05c16358f917e51f >> blob + 710cabca09101ba03c5106568a96a76da74015d0 >> --- gotd/gotd.c >> +++ gotd/gotd.c >> @@ -43,6 +43,7 @@ >> #include >> #include >> >> +#include "got_version.h" >> #include "got_error.h" >> #include "got_opentemp.h" >> #include "got_path.h" >> @@ -3404,7 +3405,7 @@ main(int argc, char **argv) >> { >> const struct got_error *error = NULL; >> struct gotd_secrets *secrets = NULL; >> - int ch, daemonize = 1, verbosity = 0, noaction = 0; >> + int ch, daemonize = 1, verbosity = 0, noaction = 0, version_flag = 0; >> const char *confpath = GOTD_CONF_PATH; >> char *secretspath = NULL; >> char *argv0 = argv[0]; >> @@ -3426,7 +3427,7 @@ main(int argc, char **argv) >> >> log_init(1, LOG_DAEMON); /* Log to stderr until daemonized. */ >> >> - while ((ch = getopt(argc, argv, "df:nP:s:T:v")) != -1) { >> + while ((ch = getopt(argc, argv, "df:nP:s:T:vV")) != -1) { >> switch (ch) { >> case 'd': >> daemonize = 0; >> @@ -3481,6 +3482,9 @@ main(int argc, char **argv) >> if (verbosity < 3) >> verbosity++; >> break; >> + case 'V': >> + version_flag = 1; >> + break; >> default: >> usage(); >> } >> @@ -3492,6 +3496,10 @@ main(int argc, char **argv) >> if (argc != 0) >> usage(); >> >> + if (version_flag) { >> + got_version_print_str(); >> + return 0; >> + } >> if (geteuid() && proc_id == GOTD_PROC_GOTD) >> fatalx("need root privileges"); >> if (geteuid() == 0 && proc_id != GOTD_PROC_GOTD) >> >> >> Thoughts/Comments/Suggestions? >> >>