girocco.git
21 months agoprojtool.pl: do not attempt to check unset error codesmaster
Kyle J. McKay [Sat, 25 Jun 2022 23:24:50 +0000 (25 16:24 -0700)]
projtool.pl: do not attempt to check unset error codes

The "do" function only sets an error code when it fails.

Attempting to clear the errors first could work, but only if the
item being "do"'d does not ever cause them to be set.

In this case the item has been set up to execute a "1" as its last
value which means there should not be any ambiguity between the
item returning "undef" as its final value and a failure causing
"do" to return "undef".

Check to see whether or not the "do" function has returned "undef"
before testing any of the error result code variables.

21 months agogit-shell-verify: only check read-only mode for receive-pack
Kyle J. McKay [Wed, 22 Jun 2022 03:30:33 +0000 (21 20:30 -0700)]
git-shell-verify: only check read-only mode for receive-pack

Limit the check for read-only mode to only incoming pushes, not
everything.  Like it was supposed to be in the first place.

21 months agogitweb/indextext_readonly.html: include sample readonly file
Kyle J. McKay [Tue, 21 Jun 2022 19:33:19 +0000 (21 12:33 -0700)]
gitweb/indextext_readonly.html: include sample readonly file

When the system has been placed in read-only mode, an alternate
home page text file will be used if one has been created.

Go ahead and provide an example alternate home page text file to
make it easier to discover and modify.

21 months agovarious: add read-only mode support
Kyle J. McKay [Tue, 21 Jun 2022 19:12:19 +0000 (21 12:12 -0700)]
various: add read-only mode support

By creating a file named "readonly" located at
$Girocco::Config::chroot/etc/readonly, external pushes and project
modifications via the web UI will be prohibited.

Modifications via local tools such as projtool or usertool are NOT
prohibited by this read-only mode, nor does this mode stop jobd or
taskd from running.

The text on the home page of the UI may be automatically altered
as well provided an alternate version of the index text file has
been made available via the gitweb_config.perl $home_text_ro setting.

If the $Girocco::Config::chroot/etc/readonly file is not empty, its
contents will also be included in the messages denying any changes.
Except for the home page, which will only show a change if $home_text_ro
points at an alternate file.

21 months agoinstall.sh: expand @cfg_name@ in processed scripts
Kyle J. McKay [Tue, 21 Jun 2022 08:37:08 +0000 (21 01:37 -0700)]
install.sh: expand @cfg_name@ in processed scripts

Make the $cfg_name value available in processed scripts that
do not have access to the full set of configuration variables.

21 months agochrootsetup_linux.sh: include libnss_files.so* in chroot
Kyle J. McKay [Tue, 21 Jun 2022 06:14:33 +0000 (20 23:14 -0700)]
chrootsetup_linux.sh: include libnss_files.so* in chroot

In addition to libnss_compat.so*, newer systems also require
libnss_files.so* as well.

Arrange to pull in the libnss_files.so* libraries if they exist and
otherwise behave as before.

22 months agojailsetup.sh: ensure safe.directory=* when running git
Kyle J. McKay [Sat, 28 May 2022 07:36:52 +0000 (28 00:36 -0700)]
jailsetup.sh: ensure safe.directory=* when running git

With this announcement:

    https://lore.kernel.org/git/xmqqv8veb5i6.fsf@gitster.g/
    "[ANNOUNCE] Git v2.35.2 and below for CVE-2022-24765"
    Date: Tue, 12 Apr 2022 10:01:21 -0700

Git versions 2.30.3, 2.31.2, 2.32.1, 2.33.2, 2.34.2 and 2.35.2 were
released on 2022-04-12 and immediately broke uses of the per-project
config setting "core.sharedrepository" when set to a non-false value.

Girocco cannot function without "core.sharedrepository" set to a
non-false value.

The following day with this announcement:

    https://lore.kernel.org/git/xmqq1qy04iqa.fsf@gitster.g/
    "[ANNOUNCE] Git v2.35.3 and below as a usability fix"
    Date: Wed, 13 Apr 2022 17:22:05 -0700

Git versions 2.30.4, 2.31.3, 2.32.2, 2.33.3, 2.34.3 and 2.35.3 were
released on 2022-04-13 providing a means to "opt-out" of the breakage
that effectively disabled use of "core.sharedrepository" set to a
non-false value.

Later versions of Git (including the since released version 2.36.0)
also contain this "opt-out" mechanism.

When Girocco runs git, it arranges for git to always use a custom
"global" git config file to ensure Girocco always runs with a
consistent Git environment (and Girocco also always disables use
of any system wide git configuration as well for the same reason).

Add the necessary configuration item to "opt-out" of the
"core.sharedrepository" breakage when running an affected Git
version.

This is harmless for older versions of Git (they simply ignore the
setting since they do not know about it) which do not require the
"opt-out" in the first place.

For versions released on or after 2022-04-13, this resolves the
issue for Girocco.

Unfortunately, those versions initially released on 2022-04-12
remain completely incompatible with Girocco.

In addition, because the 2022-04-12 release was for a CVE
(CVE-2022-24765), many distributions of Git that appear to be older,
unaffected versions, backported the CVE fix changes, thus making
them also completely incompatible with Girocco despite them appearing
to be an older, unaffected, version of Git.

Fortunately, it appears that those distributions which initially
backported the CVE fix into older versions of Git have also now
backported the subsequent fix released on 2022-04-13 to fix the fix
for the CVE.

For this reason, there's no attempt added to detect the problematic
versions of Git at this time.  For reasons stated above, simply
checking the Git version number provides inadequate checking in the
face of the backporting that took place for the CVE fix.

Checking for the issue without testing the Git version number remains
problematic as it requires the ability to change the owner of a
file in order to truly check for the incompatibility and that
generally requires super-user privileges which Girocco only currently
requires when installing a chroot jail for ssh fetch/push access.

The affected Git versions that are completely incompatible with
Girocco are expected to not be in use since they were immediately
superseded one day after their release (and the distributions that
performed a backport of the CVE fix have backported the fix for the
CVE fix).

2 years agosrc/tests: add some more hashing tests
Kyle J. McKay [Fri, 27 Aug 2021 03:31:33 +0000 (26 20:31 -0700)]
src/tests: add some more hashing tests

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: add new listalltags subcommand
Kyle J. McKay [Thu, 26 Aug 2021 00:19:17 +0000 (25 17:19 -0700)]
projtool.pl: add new listalltags subcommand

There is a preexisting toolbox/show-tags.pl utility.

While it definitely works for a list of all tags and their
counts, that's all it can do -- it cannot show which projects
the tags belong to.

Add a new listalltags subcommand to projtool.pl that brings
some additional flexibility.  It can list the tags only
without their counts as well as include the projects that
contain them.  In addition, it can filter tag names by a
Perl regular expression.

As with the show-tags.pl utility, the new listalltags subcommand
makes use of the gitweb.index.cache file in order to provide
the results very quickly.

In addition, there is a --cache-info option that can show the
current state of the gitweb.index.cache file including how
out-of-date it might be.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoGirocco/Util.pm: add some additional tag validation
Kyle J. McKay [Wed, 25 Aug 2021 21:01:23 +0000 (25 14:01 -0700)]
Girocco/Util.pm: add some additional tag validation

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: make help work properly for worktrees? command
Kyle J. McKay [Wed, 25 Aug 2021 20:40:17 +0000 (25 13:40 -0700)]
projtool.pl: make help work properly for worktrees? command

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoreadlink.c: support the -n option
Kyle J. McKay [Sun, 22 Aug 2021 20:12:10 +0000 (22 13:12 -0700)]
readlink.c: support the -n option

If there are two arguments instead of one and the first
argument is exactly '-n' then omit the trailing '\n' from
a successful result.

The '-n' option seems to be pretty much the one and only
universally supported option.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: support urls --bundle
Kyle J. McKay [Wed, 18 Aug 2021 18:34:02 +0000 (18 11:34 -0700)]
projtool.pl: support urls --bundle

With the --bundle option show the URLs for any existing downloadable
bundle files.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoProject.pm: tighten up is_empty check
Kyle J. McKay [Wed, 18 Aug 2021 18:26:28 +0000 (18 11:26 -0700)]
Project.pm: tighten up is_empty check

The "kludge" to accomodate $Girocco::Config::empty_commit_message
can leave non-empty projects undetectable.

Refuse to consider them "empty" if they have more than two loose
objects (create-initial-empty-commit makes exactly two loose objects).

While still not perfect, the check for the new conditions remains
relatively fast (no external processes needed) and will correctly
return a false "is_empty" status now for "empty" projects that have
been modified outside Girocco.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
fixup! Project.pm: tighten up is_empty check

2 years agosanity-check.pl: detect .delaygc non-empty projects
Kyle J. McKay [Wed, 18 Aug 2021 17:43:42 +0000 (18 10:43 -0700)]
sanity-check.pl: detect .delaygc non-empty projects

Other than a .clone_in_progress project, if a .delaygc project is
not empty and does not have a .allowgc file, then warn about it.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: various minor improvements
Kyle J. McKay [Wed, 18 Aug 2021 17:13:02 +0000 (18 10:13 -0700)]
projtool.pl: various minor improvements

Update/correct some of the help text.
Grok "worktrees" as well as "worktree".
For nondestructive commands that perform a function with just a
<project> argument, attempt to use "." if no <project> is given.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: accept --force with sethead for new branch
Kyle J. McKay [Wed, 18 Aug 2021 10:28:15 +0000 (18 03:28 -0700)]
projtool.pl: accept --force with sethead for new branch

There's no reason not to allow a different unborn branch name
to be set provided that's the intent.

Allow a non-existent branch name to be used with `--force`
provided it passes the valid_branch_name check.

All the code to properly handle an unborn HEAD already exists
since that's been the default state of new push projects for
some time.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: use parse_options everywhere
Kyle J. McKay [Wed, 18 Aug 2021 09:58:51 +0000 (18 02:58 -0700)]
projtool.pl: use parse_options everywhere

Replace remaining ancient code that directly inspected @ARGV
with a call to parse_options instead.  It's more robust, simpler
to use and matches the rest of the code.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: add worktree subcommand
Kyle J. McKay [Wed, 18 Aug 2021 03:06:15 +0000 (17 20:06 -0700)]
projtool.pl: add worktree subcommand

Provide a worktree subcommand for projtool.pl to make it much
simpler to add a worktree to a project.

Simply pass the arguments along to the `git worktree` command
together with a --git-dir=<project-git-directory> option.

However, as a special case, if the project is bare (the usual
case) and its HEAD branch has not been checked out in any worktree
and no explicit branch name was given, just automagically DWIM and
supply the branch name when passing along the command.  And at the
same time make it work for an unborn branch too.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoGirocco/Util.pm: add get_git_chomp function
Kyle J. McKay [Wed, 18 Aug 2021 00:35:04 +0000 (17 17:35 -0700)]
Girocco/Util.pm: add get_git_chomp function

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoshlib.sh: make var_have_git_250 available
Kyle J. McKay [Wed, 18 Aug 2021 00:05:17 +0000 (17 17:05 -0700)]
shlib.sh: make var_have_git_250 available

var_have_git_250 will be 1 if Git version 2.5.0 or later is in use.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agomarkdown.git: update to version 1.1.15
Kyle J. McKay [Sun, 15 Aug 2021 20:34:58 +0000 (15 13:34 -0700)]
markdown.git: update to version 1.1.15

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agotaskd/clone.sh: trim excessively large successful .clonelog files
Kyle J. McKay [Thu, 12 Aug 2021 02:27:13 +0000 (11 19:27 -0700)]
taskd/clone.sh: trim excessively large successful .clonelog files

If a successful clone's .clonelog file exceeds 10000 lines, trim
it back to the first 5000 lines plus a comment about how many lines
have been omitted plus the last 5000 lines.

Some very long running clones, especially git-svn clones, can produce
multi-megabyte-sized .clonelog files that are not particularly
useful, especially after a successful clone.

Retaining the first and last 5000 lines of such a log file should
more than suffice for a successful clone.

For a failed clone, the .clonelog file remains untouched.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agojobd/gc.sh: make sure all refs get packed at gc time
Kyle J. McKay [Thu, 12 Aug 2021 01:22:03 +0000 (11 18:22 -0700)]
jobd/gc.sh: make sure all refs get packed at gc time

If there are any refs in the private refs area, make sure that
they get packed too at the same time refs in the main area do.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojects: make application/json the default initial jsontype
Kyle J. McKay [Wed, 4 Aug 2021 04:20:35 +0000 (3 21:20 -0700)]
projects: make application/json the default initial jsontype

The old 'application/x-www-form-urlencoded' type continues to be
supported; any projects that existed prior to the addition of the
"jsontype" setting and do not have it configured will continue to
be interpreted as 'application/x-www-form-urlencoded' when loaded
to preserve backwards compatibility.

For new projects though, make the default the more modern
'application/json' type instead of the outdated
'application/x-www-form-urlencoded' type.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: add missing nested braces
Kyle J. McKay [Wed, 4 Aug 2021 04:06:12 +0000 (3 21:06 -0700)]
projtool.pl: add missing nested braces

The "redo" statement requires an actual block; a bunch of statements
grouped in a pair of braces ('{'...'}') as part of a conditional
does not qualify.

Add the necessary extra pair of braces to make the bodies of these
conditionals that use `redo` actually be able to `redo`.

This was previously handled properly, but when some new options
were added the extra pair of braces was overlooked for them.

Add them now to correct the problem.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years ago.gitignore: ignore any __BASEDIR__ symlinks
Kyle J. McKay [Wed, 4 Aug 2021 04:00:04 +0000 (3 21:00 -0700)]
.gitignore: ignore any __BASEDIR__ symlinks

Later perls do not contain the current directory (".") by default
in their include path.

In order to successfully run `perl -c` on the various perl scripts,
they must be able to find their include files.

Prior to install they contain a `use lib "__BASEDIR__"` line that
gets modified at install time to reflect the actual location of the
include base directory.

In order to use `perl -c` on the uninstalled versions, an explicit
`-I.` argument must be provided.

This can get especially tedious after a while.

An alternative is to create a symlink from __BASEDIR__ in the current
directory to `.` (or whereever the root of the include tree is
actually located).

While quite convenient, it's something to be added by individual
developers according to their preference rather than just blindly
adding such a symlink to the repository thereby affecting everyone.

However, to facilitate such use, it doesn't hurt to add an ignore
pattern for `__BASEDIR__` to the top-level .gitignore to help prevent
any possible accidents where such a link might get added and committed
unintentionally.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoupdate-all-config.pl: check private refs area config
Kyle J. McKay [Mon, 2 Aug 2021 03:55:48 +0000 (1 20:55 -0700)]
update-all-config.pl: check private refs area config

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: quiety accept --git-dir as verify option
Kyle J. McKay [Mon, 2 Aug 2021 03:47:53 +0000 (1 20:47 -0700)]
projtool.pl: quiety accept --git-dir as verify option

To find the current git directory with Git the command is
`git rev-parse --git-dir`.

When using the `projtool.pl verify --dir` command there might be
some confusion and an attempt to use `projtool.pl verify --git-dir`
instead.

It's unambiguous, just make it quietly work as an alias for --dir.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoupdate-all-config.pl: correct cosmetic message output issue
Kyle J. McKay [Mon, 2 Aug 2021 03:36:10 +0000 (1 20:36 -0700)]
update-all-config.pl: correct cosmetic message output issue

Messages could be output with improper end-of-line characters
resulting in distorted message display.

The code was there to make sure that didn't happen but was
not fully hooked up.

Hook it up now.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoProject.pm: initialize private refs area at project creation
Kyle J. McKay [Mon, 2 Aug 2021 03:12:25 +0000 (1 20:12 -0700)]
Project.pm: initialize private refs area at project creation

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agobin/create-*-area: make sure all messages go to stderr
Kyle J. McKay [Mon, 2 Aug 2021 03:09:50 +0000 (1 20:09 -0700)]
bin/create-*-area: make sure all messages go to stderr

Add missing '>&2' to a couple of lines that don't already have it.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agocreate_projects_bom.pl: include subdir packed-refs if present
Kyle J. McKay [Sat, 31 Jul 2021 06:02:30 +0000 (30 23:02 -0700)]
create_projects_bom.pl: include subdir packed-refs if present

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: add --dir option to verify subcommand
Kyle J. McKay [Sat, 31 Jul 2021 05:42:58 +0000 (30 22:42 -0700)]
projtool.pl: add --dir option to verify subcommand

With --dir output the canonical path to the project instead
of its name.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agolighttpd.conf.in: add some fine tuning and comments
Kyle J. McKay [Wed, 7 Jul 2021 06:11:10 +0000 (6 23:11 -0700)]
lighttpd.conf.in: add some fine tuning and comments

Although the config works fine for Girocco the way it is now, there
are some lighttpd idiosyncrasies that just happen to not affect
Girocco.

Mention these issues and add a few extra settings to address them
to make sure any added non-Girocco scripts don't run into them.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agomake-{apache,lighttpd}-conf.sh: make sure var_getconfpath available
Kyle J. McKay [Wed, 7 Jul 2021 06:09:15 +0000 (6 23:09 -0700)]
make-{apache,lighttpd}-conf.sh: make sure var_getconfpath available

In the same way that var_online_cpus has been made available early
for processing of the config files, do the same for var_getconfpath.

It's convenient to have the value available for scripts configuration.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoshlib.sh: provide var_getconfpath variable
Kyle J. McKay [Wed, 7 Jul 2021 05:12:30 +0000 (6 22:12 -0700)]
shlib.sh: provide var_getconfpath variable

Stuff the output of the Girocco::Dumper::GetConfPath function into
the `var_getconfpath` variable for use by shell scripts and so
forth.

It's slightly more reliable than `getconf PATH` as it "sanitizes"
the result of `getconf PATH` to exclude any "." components and that
makes it helpful to have available for scripts.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoGirocco/Config.pm: mention Git's reference-transaction hook
Kyle J. McKay [Mon, 5 Jul 2021 02:03:30 +0000 (4 19:03 -0700)]
Girocco/Config.pm: mention Git's reference-transaction hook

The reference-transaction hook added in Git v2.28.0 makes most of
what the $autogchack does unnecessary.  However, based on an
unfortunate design decision in the implemenation of the
reference-transaction hook, Girocco still must keep track of the
old value of any updated refs to generate the correct change notices.

It does this anyway for all mirrors already, not a big deal.

For now, just mention that the reference-transaction hook has been
available since Git v2.28.0; eventually, changes will be made to
take advantage of the new hook to obsolete the $autogchack setting
when running with a Git >= 2.28.0.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: add verify command
Kyle J. McKay [Fri, 2 Jul 2021 21:50:21 +0000 (2 14:50 -0700)]
projtool.pl: add verify command

Provide a verify command in much the same vein as Git's
`git rev-parse --verify` invocation.

When given a project name or path, resolve that to the actual
project, verify that it exists and can be loaded and then show its
canonical project name on standard out and exit with success.

Otherwise exit with an error code.  Diagnostic messages are shown
on standard error unless `--quiet` has been used.

The verify command provides a convenient way to take advantage of
the path-to-project translation facility from the command line.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: allow existing projects to be specified by path
Kyle J. McKay [Fri, 2 Jul 2021 20:55:12 +0000 (2 13:55 -0700)]
projtool.pl: allow existing projects to be specified by path

Where an existing project is required, accept a path to that
project and make a best effort attempt to translate that path
to a project name before giving up with an error.

For safety, make the remove command continue to only accept
project names.  The prune command, by its very nature, only
accepts project names as it's looking for missing directories.

Add a note about all this to the beginning of the help output
including a mention of the convenient "." shortcut.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoCLIUtil.pm: try harder in get_project
Kyle J. McKay [Fri, 2 Jul 2021 20:16:55 +0000 (2 13:16 -0700)]
CLIUtil.pm: try harder in get_project

As CLIUtil provides services for command line clients, allow a path
to be passed in to get_project instead of just a project name.

However, only activate the "try harder" code if an optional second
argument is passed that has a "true" value.

Provide a new convenience/self-documenting function `get_project_harder`
that calls get_project with its first arg and passes true for the
second.

This way the "allow a path" logic remains opt-in only to avoid any
unexpected nasty surprises.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoGirocco/Util.pm: add get_project_from_dir function
Kyle J. McKay [Fri, 2 Jul 2021 02:07:41 +0000 (1 19:07 -0700)]
Girocco/Util.pm: add get_project_from_dir function

Provide functionality similar to shlib.sh's v_get_proj_from_dir
function via a new get_project_from_dir subroutine.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoprojtool.pl: accept gc --aggressive for --force --redelta
Kyle J. McKay [Fri, 2 Jul 2021 00:09:11 +0000 (1 17:09 -0700)]
projtool.pl: accept gc --aggressive for --force --redelta

The standard `git gc` command accepts no options, `--auto` and
`--aggressive` to activate various modes.  By adding support for
`--aggressive` it becomes a simple matter to translate the normal
`git gc` command into the equivalent `projtool.pl gc` command without
needing to exercise the gray matter.

The equivalent of `git gc --aggressive` as far as `projtool.pl gc`
is concerned is just `projtool.pl gc --force --redelta` which is
already supported.

Make `--aggressive` activate the `--force` and `--redelta` options.

Since a plain `projtool.pl gc` already roughly corresponds to a
plain `git gc` and a `projtool.pl gc --auto` already roughly
corresponds to `git gc --auto` this change completes the trifecta.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agochrootsetup_*: make sure pull_in_lib libraries have +/-x
Kyle J. McKay [Mon, 28 Jun 2021 02:26:36 +0000 (27 19:26 -0700)]
chrootsetup_*: make sure pull_in_lib libraries have +/-x

When pulling in libraries into the chroot, do make sure that they
either end up with 0755 or 0644 depending on whether or not the
result of `test -x` thinks they're executable.

Whether or not a shared library file has +x or not seems to vary
wildly with apparently no obvious rhyme or reason to it.

When running as root to set up the chroot, the `test -x`
utility will conveniently return a "true" result if *any* of
the executable bits are set and a "false" result otherwise.

Propagate the result of the `test -x` check to all the executable
bits to make sure the library installed in the chroot is consistent
with regards to whether or not it's actually "executable".

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agochrootsetup_*: make sure pull_in_bin binaries are 0755
Kyle J. McKay [Mon, 28 Jun 2021 01:28:07 +0000 (27 18:28 -0700)]
chrootsetup_*: make sure pull_in_bin binaries are 0755

When pulling in binaries into the chroot, do make sure that they
end up with permissions 0755 regardless of what they started out
with.  If they were built under odd circumstances, they could
possibly have unusual permissions.

A future update ought to do the same thing for pulled in libraries.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoUtil.pm/CLIUtil.pm: clean up abnormal exit code handling
Kyle J. McKay [Sun, 27 Jun 2021 23:13:30 +0000 (27 16:13 -0700)]
Util.pm/CLIUtil.pm: clean up abnormal exit code handling

When the setup_pager function arranges for STDOUT to be paged,
it was causing the exit code of the process (when using the
special "become child" feature) to be that of the pager rather
than the program itself.  Fix this to capture the exit status
of the real program and then exit with that value instead.

When the noFatalsToBrowser function disables the CGI redirection
of die from the unreadable-when-dumped-on-the-terminal output
to something more legible, it inspects the various error variables
to determine what exit code it should use (if it's not in an
eval block).

In both of these cases, be careful to make sure that the exit
code used is in the range 0..255 inclusive and furthermore, that
if the exit was caused by a signal that it's the 128+signal_num
value rather than the bare signal_num value.

Force unexpected exit codes outside the 0.255 range to be 255.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agotoolbox/projtool.pl: add urls subcommand
Kyle J. McKay [Sun, 27 Jun 2021 21:40:15 +0000 (27 14:40 -0700)]
toolbox/projtool.pl: add urls subcommand

Add a convenient "urls" subcommand to display the various Git
fetch/push URLs that are available for a project and would be
shown by gitweb.cgi thereby making this information easily
obtainable directly from the command line.

As a convenience allow the URLs to be limited to only "push"
URLs with the --push option.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agogitweb_config.perl: add a few extra "our" declarations
Kyle J. McKay [Sun, 27 Jun 2021 20:50:37 +0000 (27 13:50 -0700)]
gitweb_config.perl: add a few extra "our" declarations

It's most convenient to be able to load the "gitweb_config.perl"
configuration outside of gitweb.cgi.

Make that easier to accomplish by adding a couple of "our"
declarations for the two hashes (feature and html_cache_actions)
that have values set.

This makes it clear what's supposed to happen when those two
hashes have items set in them and makes it simpler to "use" the
gitweb_config.perl file from a location outside gitweb.cgi.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoProject.pm/Validator.pm: switch to refactored valid_branch_name check
Kyle J. McKay [Sun, 27 Jun 2021 20:20:26 +0000 (27 13:20 -0700)]
Project.pm/Validator.pm: switch to refactored valid_branch_name check

Replace the haphazard regex that has become unmaintainable (and
incomplete) with a call to the new valid_branch_name function instead.

This results in more readable and maintainable code.

Be careful with the call out from Girocco::Validator as unusual
scoping is in effect while validating and an explicit call to the
actual Girocco::ValidUtil::valid_branch_name function must be used.
Together with that, be careful to avoid import name pollution too.

To make this easy, modify Girocco::Util to automatically use the
new Girocco::ValidUtil module and export its valid_branch_name
function along with all the other valid_xxx functions.

The other valid_xxx functions in Girocco::Util are just begging to
be moved into the new Girocco::ValidUtil module.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoGirocco/ValidUtil.pm: refactor valid branch name check
Kyle J. McKay [Sun, 27 Jun 2021 19:51:33 +0000 (27 12:51 -0700)]
Girocco/ValidUtil.pm: refactor valid branch name check

The branch name checking regular expression has become more-or-less
unreadable:

    /^\/|^\.|[\x00-\x1f \x7f\[\[~^"'"<>*?\\:]|\@\{|\.\.|\.lock$|\.$|\/$/

And is duplicated in three different places while not managing to catch
all the restrictions enforced by Git (see `git help check-ref-format`).

The fact that if you look closely at it you can even see it checking
for the same disallowed character twice (the '[') character.

This suggests it has become somewhat unmaintainable in its current form.

One challenge is that it's used by the install-time-only
Girocco::Validator module and at runtime by the Girocco::Project module.

Its use by the Girocco::Validator module makes it particularly
tricky to refactor since the Girocco::Validator module validates
the Girocco::Config module which pretty much all the other
currently existing Girocco modules "use".  Therefore moving the
validation expression into Girocco::Util will simply not work
(because then Girocco::Validator would need to "use" that module
which in turn "use"s Girocco::Config which Girocco::Validator is
trying to validate -- a bad idea).

Create a new Girocco::ValidUtil module that does not "use" any other
modules but exports a suitable `valid_branch_name` function for use
by other modules.

Take this opportunity to explicitly list all the rules it enforces,
fix the items it was failing to catch and make the regex much more
readable and understandable by using the "/x" modifier.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoinit: optionally create an initial empty commit
Kyle J. McKay [Tue, 15 Jun 2021 16:59:01 +0000 (15 09:59 -0700)]
init: optionally create an initial empty commit

If the new setting $Girocco::Config::empty_commit_message is defined
(it can be the empty string) then when creating a new push project,
create an initial commit that has the empty tree and the given
$Girocco::Config::empty_commit_message as its commit message.

What this does is cause a remote client that's cloning the newly
created push project to automatically set up the HEAD symbolic ref
to match whatever the $initial_branch setting has been set to (as
well as suppress the "You appear to have cloned an empty repository."
message).

It's no less convenient for the remote user since the commit has
an empty tree.  It may be a bit surprising to find an empty commit
already present.  That's why this setting is off by default.

However, when it's important that the $initial_branch setting be
respected by the remote client on a newly created push project,
setting $Girocco::Config::empty_commit_message to any value will
help make sure that happens.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoGirocco/Config.pm: add jgit_compatible_bitmaps note
Kyle J. McKay [Tue, 15 Jun 2021 13:56:31 +0000 (15 06:56 -0700)]
Girocco/Config.pm: add jgit_compatible_bitmaps note

Since the JGit v3.5.0 release in late 2014, JGit can deal with
Git's bitmap hash cache.  In fact, since Git v2.22.0 (released
2019-06-07), Git enables the hash cache by default since that's
approximately 5 years since JGit learned to deal with it.

Mention this information in the comments for the obscure
$Girocco::Config::jgit_compatible_bitmaps setting to provide more
guidance about when it may actually need to be activated.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agomarkdown.git: update to version 1.1.14
Kyle J. McKay [Mon, 14 Jun 2021 21:49:58 +0000 (14 14:49 -0700)]
markdown.git: update to version 1.1.14

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoinit: provide config option for initial branch of push projects
Kyle J. McKay [Mon, 14 Jun 2021 18:56:03 +0000 (14 11:56 -0700)]
init: provide config option for initial branch of push projects

Add new $Girocco::Config::initial_branch configuration option that
allows the name of the initial unborn branch in newly created push
projects to be configured.

Make this configuration option work with any Git version.

To provide consistency, if the option is not set, is the empty
string or is invalid, always use the historical name for the initial
unborn branch in a newly created Git repository (i.e. "master").

Even without this support in place, if a different first branch
(other than the unborn branch that `HEAD` points at) gets pushed
to a newly created empty push project, `HEAD` will be automatically
updated to point to that branch.

With this support in place and a different initial branch name set,
one would hope that cloning that initial, empty push project would
automatically configure the initial branch name to match thus making
everything just a tad bit more convenient.

Unfortunately the reality bites.  Git fails to send any capabilities
at all when a project has no refs and the operation is not a push
(in contrast to JGit).  Furthermore, Git will always omit the
symref=HEAD:... capability when the HEAD symbolic-ref is still
unborn.  Additionally, even if a special setup is used that does
send the initial capabilities (like JGit) and does include the
symref=HEAD: capability even when the HEAD symbolic-ref is still
unborn, Git will ignore it when setting up the empty repository
clone!  Major FAIL for Git!

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agomarkdown.git: update to version 1.1.13
Kyle J. McKay [Sun, 13 Jun 2021 20:31:12 +0000 (13 13:31 -0700)]
markdown.git: update to version 1.1.13

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agosrc/dragonfly/README: mention latest releases have nc
Kyle J. McKay [Fri, 4 Jun 2021 13:02:46 +0000 (4 06:02 -0700)]
src/dragonfly/README: mention latest releases have nc

Since the DragonFly BSD 4.8.0 release on 2017-03-27, the nc
utility has been included as part of the base system courtesy
of the netcat (nc) app that's part of LibreSSL.

Since that *is* the OpenBSD version of nc and therefore *does*
support the `-U` option, it's not necessary to build an
alternative on the newer DragonFly BSD releases.

Add a note to the README mentioning this fact.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agopeek_packet.c: update comments to reflect remote_port addition
Kyle J. McKay [Wed, 2 Jun 2021 06:36:49 +0000 (1 23:36 -0700)]
peek_packet.c: update comments to reflect remote_port addition

Since commit c3a65d0203c00d96 ("peek_packets.c: provide remote_port
value", 2020-11-24), a remote_port= output line has been provided
along with the remote_addr= output line.

Update the comments (that serve as documention) to reflect this change.

There's no functional change, only comments are updated.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agorun-format-readme.sh: handle non-root gitweb.cgi readme fragments
Kyle J. McKay [Mon, 3 May 2021 02:03:31 +0000 (2 19:03 -0700)]
run-format-readme.sh: handle non-root gitweb.cgi readme fragments

When the $Girocco::Config::gitweburl value does not point at a
"root" path (e.g. "http://some.example.com/") for gitweb.cgi, then
that must be accounted for when fixing up fragment links just like
it is when creating image/text links.

Use the first part of the "img" construction to make sure the
result works when gitweburl is not a "root" path.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agogitweb: update fallback FastCGI version 1.0.0 -> 1.0.1
Kyle J. McKay [Mon, 3 May 2021 01:56:32 +0000 (2 18:56 -0700)]
gitweb: update fallback FastCGI version 1.0.0 -> 1.0.1

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
2 years agoproject-disk-use.sh: add legend char to orphaned line
Kyle J. McKay [Thu, 22 Apr 2021 00:16:05 +0000 (21 17:16 -0700)]
project-disk-use.sh: add legend char to orphaned line

Orphan projects (if any are found) are suffixed with '!' to
indicate that they are orphans.

Add the legend prefix character ('!') to the summary line as
a hint to this meaning in the same way the active projects
prefix character ('*') and "banged" projects character ('~')
are already present as summary line prefix characters.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agobin/format-readme: use Markdown.pl --strip-comments-lax-only option
Kyle J. McKay [Thu, 18 Mar 2021 04:52:13 +0000 (17 21:52 -0700)]
bin/format-readme: use Markdown.pl --strip-comments-lax-only option

Instead of forcing strictly invalid XML comments to become escaped,
plain text, just strip them out for a much nicer looking result.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/Project.pm: use --strip-comments-lax-only for Markdown readme
Kyle J. McKay [Thu, 18 Mar 2021 04:51:32 +0000 (17 21:51 -0700)]
Girocco/Project.pm: use --strip-comments-lax-only for Markdown readme

Make use of the new --strip-comments-lax-only option to allow README
content that would otherwise be invalid XML to be accepted when the
only problem is that it contains a strictly invalid XML comment.

The solution simply strips any such invalid comments.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agomarkdown.git: update to version 1.1.12
Kyle J. McKay [Thu, 18 Mar 2021 04:32:14 +0000 (17 21:32 -0700)]
markdown.git: update to version 1.1.12

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoconfig: compute var_umask, var_umask_ug and var_umask_perm
Kyle J. McKay [Tue, 16 Mar 2021 04:23:21 +0000 (15 21:23 -0700)]
config: compute var_umask, var_umask_ug and var_umask_perm

While validating the $Girocco::Config::git_shared_repository setting,
compute new var_umask, var_umask_ug and var_umask_perm values.

The var_umask value is the octal umask corresponding to the value
of the $Girocco::Config::git_shared_repository setting.

The var_umask_ug value is the var_umask value with "other" permissions
masked out (i.e. it's been "or"'d with 007).

The var_umask_perm value is either var_umask if the permission_control
(aka $Girocco::Config::permission_control) is 'Group' (the default) or
0 if the permission_control is 'Hooks'.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoconfig: use core.sharedRepository=2 by default
Kyle J. McKay [Mon, 15 Mar 2021 05:26:09 +0000 (14 22:26 -0700)]
config: use core.sharedRepository=2 by default

Instead of initializing repositories using core.sharedRepository=1,
switch to using core.sharedRepository=2 by default.

Add an obscure setting that allows this to be controlled.

Make sure update-all-config.pl understands the new setting.

Since the umask is often set to something no more restrictive
than 002, in practice, the previous default of 1 was usually
acting like a default of 2.

However, in order to run something like git-daemon to serve
repositories over git: protocol while git-daemon is running as
the 'nobody' user, the repositories need to always be world
readable.  Setting core.sharedRepository=2 makes sure this
happens.

While it was mostly happening by default anyway thanks to the
behavior of core.sharedRepository=1 and the usual setting of
the umask to 002, make it explicit with core.sharedRepository=2.

With this new setting, accessing the repositories via non-Girocco
means directly via `git` with a umask that masks out all 'other'
permissions will no longer result in repositories that cannot be
served properly by a daemon running as the 'nobody' user.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agolint-all-readme.pl: allow running on specific projects only
Kyle J. McKay [Sat, 13 Mar 2021 00:38:52 +0000 (12 17:38 -0700)]
lint-all-readme.pl: allow running on specific projects only

If one (or more) explicit project names are given, operate only
on those projects rather than the entire list of known projects.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agotagproj.cgi: require matching referer header
Kyle J. McKay [Wed, 10 Mar 2021 07:26:16 +0000 (10 00:26 -0700)]
tagproj.cgi: require matching referer header

The idea being that only a request made from the actual project's
summary page should be allowed to set a tag.

Check for this via the "Referer" header and if it does not match
the project being tagged, refuse to add the tag.

While this only provides minimal protection from tag spammers,
what it does guarantee is that the project any tagproj.cgi POST
requests are tagging can be reliably identified from the referer
item in the log file -- a great help to identifying the source
of any unwanted tag spamming.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoulimit512: use getrlimit and setrlimit if available
Kyle J. McKay [Tue, 9 Mar 2021 23:47:33 +0000 (9 16:47 -0700)]
ulimit512: use getrlimit and setrlimit if available

The old ulimit function is no longer preferred.  If the
getrlimit/setrlimit functions are available, use them instead.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agosanity-check.pl: field 4 is really field 5
Kyle J. McKay [Tue, 9 Mar 2021 21:35:25 +0000 (9 14:35 -0700)]
sanity-check.pl: field 4 is really field 5

Change "field-4-not-empty" to be "field-5-not-empty" since
the human-readable field numbers start counting from 1 not 0.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agotoolbox/update-all-config.pl: quiet means quiet
Kyle J. McKay [Mon, 8 Mar 2021 04:15:02 +0000 (7 21:15 -0700)]
toolbox/update-all-config.pl: quiet means quiet

Add missing checks for $quiet so that --quiet really means
quiet rather than sorta, kinda quiet but not really.

And might as well tidy up the calls to $progress -- it's
not necessary to keep a counter if it's updated by 1 each time.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoinstall.sh: make sure installed files have correct permissions
Kyle J. McKay [Mon, 8 Mar 2021 03:12:33 +0000 (7 20:12 -0700)]
install.sh: make sure installed files have correct permissions

If the user building girocco and running the 'make install'
command has an excessively strict umask (e.g. 0077), files that
have been created may lack the needed read/execute access for
group/other as required for proper functioning of the web/chroot
facilities.

Make sure the necessary permissions are always set during the
"finalizing permissions" stage.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoedit-user-email/remove-user: redirect to usertool.pl
Kyle J. McKay [Mon, 8 Mar 2021 02:45:05 +0000 (7 19:45 -0700)]
edit-user-email/remove-user: redirect to usertool.pl

Changing a user's email address and removing a user can both
be performed by usertool.pl.

These scripts are quite possibly outdated and may be unsafe.

Redirect them to the equivalent usertool.pl command instead.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agousertool.pl: allow specifying old email for email change
Kyle J. McKay [Mon, 8 Mar 2021 02:07:12 +0000 (7 19:07 -0700)]
usertool.pl: allow specifying old email for email change

If the old email address does not match the specified value,
refuse to make the change.

Providing the old email address is optional.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoupdate-all-hooks: convert to show better progress and errors
Kyle J. McKay [Mon, 8 Mar 2021 01:46:41 +0000 (7 18:46 -0700)]
update-all-hooks: convert to show better progress and errors

Use the new Progress class to show a better running
progress indicator since this operation can take a
very long time when there are many projects and it's
been run nice'd.

Take advantage of the conversion to also show better
error messages on any failures.

Functionality remains unchanged.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/CLIUtil.pm: join progress message arguments with ' '
Kyle J. McKay [Sun, 7 Mar 2021 23:44:25 +0000 (7 16:44 -0700)]
Girocco/CLIUtil.pm: join progress message arguments with ' '

If more than one message argument is passed to the
Girocco::CLIUtil::Progress->emitfh method, join them together
with a ' ' and use that as the message.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoclear-all-htmlcache.pl: tidy up and be nice
Kyle J. McKay [Sat, 6 Mar 2021 07:09:08 +0000 (6 00:09 -0700)]
clear-all-htmlcache.pl: tidy up and be nice

Remove unnecessary counter as counting up by one is the
default for a Progress->update call.  Also omit the clear
as that's automatic on destroy, but do invoke destroy by
undef'ing the object.

Be nice to avoid interfering with other server activities.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agolint-all-readme.pl/sanity-check.pl: be nice
Kyle J. McKay [Sat, 6 Mar 2021 06:59:37 +0000 (5 23:59 -0700)]
lint-all-readme.pl/sanity-check.pl: be nice

Call nice_me to make sure that running these introspection
commands does not take out the server (or at lease impair
its performance in a noticeable way).

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoshow-pack-counts.pl: switch to Girocco::CLIUtil::Progress class
Kyle J. McKay [Sat, 6 Mar 2021 06:50:53 +0000 (5 23:50 -0700)]
show-pack-counts.pl: switch to Girocco::CLIUtil::Progress class

Eliminate code duplication and use the new Progress class.

The output is very similar, but with the actual current progress
count shown.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoupdate-all-config.pl: add nice progress indicator
Kyle J. McKay [Sat, 6 Mar 2021 05:38:43 +0000 (5 22:38 -0700)]
update-all-config.pl: add nice progress indicator

Use the new Girocco::CLIUtil::Progress class to add a nice
progress indicator to the output.

Also sneak in a tiny change to make the project sort order
stable.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agomarkdown.git: update to version 1.1.11
Kyle J. McKay [Sat, 6 Mar 2021 04:58:58 +0000 (5 21:58 -0700)]
markdown.git: update to version 1.1.11

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agohelp: make sure help shows with nice formatting
Kyle J. McKay [Fri, 5 Mar 2021 12:21:19 +0000 (5 05:21 -0700)]
help: make sure help shows with nice formatting

Starting with Perl 5.28.0, the default output when using
Pod::Usage with a verbose level >= 2 has been made plain,
ugly, no formatting whatsoever.

Compensate for this documentation travesty by setting
the PERLDOC environment variable, if it's not already set,
to restore the previous behavior.

Additionally, add the necessary changes so that the brief
help shown for '-h' will use terminal formatting codes to
show bold, underline, etc., if available, to avoid the very
ugly plain text mess that would otherwise appear.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/CLIUtil.pm: provide Progress warn method
Kyle J. McKay [Fri, 5 Mar 2021 10:17:45 +0000 (5 03:17 -0700)]
Girocco/CLIUtil.pm: provide Progress warn method

While the "emit" method outputs to STDOUT, the new "warn" method
outputs to STDERR and the new "emitfh" method accepts a file
handle as the first argument.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoProject.pm/User.pm: split validated match not $_
Kyle J. McKay [Fri, 5 Mar 2021 09:51:23 +0000 (5 02:51 -0700)]
Project.pm/User.pm: split validated match not $_

In the get_full_list_extended functions, split the validated
pattern match capture rather than $_.  That way it's untainted.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoclear-all-htmlcache.pl: convert to show better progress
Kyle J. McKay [Fri, 5 Mar 2021 09:38:23 +0000 (5 02:38 -0700)]
clear-all-htmlcache.pl: convert to show better progress

Use the new Progress class to show a better running
progress indicator since this operation can take a
very long time when there are many projects and it's
been run nice'd.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agotoolbox/sanity-check.pl: sanity checking tool
Kyle J. McKay [Thu, 4 Mar 2021 07:32:06 +0000 (4 00:32 -0700)]
toolbox/sanity-check.pl: sanity checking tool

Add sanity-check.pl tool that performs basic sanity checking
on users and projects displaying an abbreviated summary of
any issues uncovered for each user and project checked.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/User.pm: add get_full_list and get_full_list_extended
Kyle J. McKay [Thu, 4 Mar 2021 05:53:54 +0000 (3 22:53 -0700)]
Girocco/User.pm: add get_full_list and get_full_list_extended

Add equivalent functions of the same name to those provided
by Girocco/Project.pm that read directly and only from the
file that is the source of all truth for the list of users.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/Config.pm: alter PATH adjustment advice
Kyle J. McKay [Thu, 4 Mar 2021 05:25:17 +0000 (3 22:25 -0700)]
Girocco/Config.pm: alter PATH adjustment advice

Instead of trying to munge the output of qx(getconf PATH),
suggest using the Girocco::Dumper::GetConfPath function
since it knows how to properly sanitize the result.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/Dumper.pm: make GetConfPath more paranoid
Kyle J. McKay [Thu, 4 Mar 2021 05:17:55 +0000 (3 22:17 -0700)]
Girocco/Dumper.pm: make GetConfPath more paranoid

Believe it or not, some systems respond to this:

    /usr/bin/getconf PATH

With something like this:

    /usr/bin:/bin:/usr/sbin:/sbin:

Notice the bogus extra ":" on the end!  That would cause
the current directory to be searched!

Process the value returned by `getconf PATH` to expunge
any non-absolute-path directories and any paths that contain
a '/.' sequence to make sure the result is reasonably secure.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agolint-all-readme.pl: switch to Girocco::CLIUtil::Progress
Kyle J. McKay [Thu, 4 Mar 2021 03:05:32 +0000 (3 20:05 -0700)]
lint-all-readme.pl: switch to Girocco::CLIUtil::Progress

Remove original Progress class code in favor of the new
version now located in Girocco/CLIUtil.pm.

Take advantage of the new emit method at the same time.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/CLIUtil.pm: add Girocco::CLIUtil::Progress class
Kyle J. McKay [Thu, 4 Mar 2021 02:59:17 +0000 (3 19:59 -0700)]
Girocco/CLIUtil.pm: add Girocco::CLIUtil::Progress class

Move and improve the Progress class from lint-all-readme.pl
into Girocco/CLIUtil.pm as Girocco::CLIUtil::Progress.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoProject.pm: more or less more validation of user list on load
Kyle J. McKay [Thu, 4 Mar 2021 00:52:11 +0000 (3 17:52 -0700)]
Project.pm: more or less more validation of user list on load

The validation of the users field that was recently added was
trying to be clever and be reasonably "loose" with the check
while detecting blatantly invalid user names.

It was using Perl's '\w' (word character) match operator to
do this.

Unfortunately, that's too strict.  The characters '-', '+',
'.' and '_' are allowed in user names provided they are not
the first character.  Only '_' is matched by Perl's '\w'.

Replace the nice and convenient '\w+' with a much less
compact regex that allows the additional characters.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoinstall.sh: accomodate newer OpenSSL breakage
Kyle J. McKay [Thu, 4 Mar 2021 00:20:05 +0000 (3 17:20 -0700)]
install.sh: accomodate newer OpenSSL breakage

Older versions of OpenSSL (and all versions of LibreSSL) output
the result of `openssl x509 -noout -subject` like so:

    subject= /CN=localhost

On the other hand, newer OpenSSL versions have determined to break
parsers that expect that output by changing it to look like so:

    subject=CN = localhost

Add suitable munging (very ugly) so that either output will end
up providing the string we're looking for (the first version with
the leading "subject= " stripped off).

With this change, the certificate and certificate chain stops
being regenerated on every install even when it's unnecessary.

It's harmless to do so (other than a minor waste of CPU time) since
the generation is deterministic and always produces the same output
when given the same input (which is the case here).

There may be some (bizarre) option to make the more recent versions
of OpenSSL output in the older format, but then that option would
likely not work with the older versions and a different kind of
ugliness would ensue attempting to determine whether or not to
pass the option to avoid breakage that way.

The ugliness being used here does not depend on passing any magic and
unreliable options to the `openssl` command to avoid such issues.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoprojtool.pl: paranoidify prune pick
Kyle J. McKay [Wed, 3 Mar 2021 18:38:57 +0000 (3 11:38 -0700)]
projtool.pl: paranoidify prune pick

Make the prune command be even more paranoid about items to
remove.  Specifically guarantee the gid is at least 65536 and
the name starts with an alphanumeric or don't even consider
the possibility of pruning that entry at all.

Also tidy up the wording a bit to indicate that entries are
being removed rather than the entire project.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/Project.pm: add get_full_list_extended function
Kyle J. McKay [Wed, 3 Mar 2021 18:24:42 +0000 (3 11:24 -0700)]
Girocco/Project.pm: add get_full_list_extended function

The existing get_full_list function returns the list of
project names by reading the group file directly.

Add a new get_full_list_extended function that does the same
thing but returns an array of array refs consisting of all
the individual fields rather than just the names.

Tighten up the check a bit to only return items with a gid
>= 10000 rather than just 5 or more digits.

Add some comments explaining the return value for the functions.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agomarkdown.git: update to newer version
Kyle J. McKay [Wed, 3 Mar 2021 07:33:42 +0000 (3 00:33 -0700)]
markdown.git: update to newer version

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agotoolbox/lint-all-readme.pl: new utility to check readme data
Kyle J. McKay [Tue, 2 Mar 2021 08:43:29 +0000 (2 01:43 -0700)]
toolbox/lint-all-readme.pl: new utility to check readme data

When run without --dry-run, attempt to update any README.html
files that do not match the result of processing README.dat
based on the rmtype value.

Also report any projects that fail the _lint_readme call
entirely.

With --dry-run report but do not update.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/Project.pm: implement _property_fput nosetsame for file props
Kyle J. McKay [Tue, 2 Mar 2021 08:36:05 +0000 (2 01:36 -0700)]
Girocco/Project.pm: implement _property_fput nosetsame for file props

When requested, avoid rewriting exactly the same data to file-based
properties provided the file exists and can be read and contains
exactly the same data that would be written.

Support for this behavior for non-file-based properties already
existed and this brings parity for the file-based properties.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoGirocco/HashUtil.pm: take advantage of Digest::SHA::hmac_sha1
Kyle J. McKay [Tue, 2 Mar 2021 01:16:40 +0000 (1 18:16 -0700)]
Girocco/HashUtil.pm: take advantage of Digest::SHA::hmac_sha1

If Digest::SHA::hmac_sha1 can be imported, then use that as the
hmac_sha1 implementation.

It's approximately twice as fast (almost) as the included
hmac_sha1 implementation.

When using the Digest::SHA::hmac_sha1 implementation, double the
maximum key rounds since that's approximately the same CPU cost.

Clients of the HashUtil module automatically get whatever is
implementing hmac_sha1 imported as hmac_sha1 and do not need to
make any changes whatsoever.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agoprojtool/usertool: default paging to off for most commands
Kyle J. McKay [Tue, 2 Mar 2021 00:34:09 +0000 (1 17:34 -0700)]
projtool/usertool: default paging to off for most commands

For commands that are not expected to produce very much output
if any at all and do not require that the pager always be disabled
because they prompt for input, set the pager to off by default.

It can still be explicitly enabled for these commands, but
setting it off by default makes more sense especially for
commands that will be modifying settings and might return
a non-zero exit status that would otherwise be lost to
the pager.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
3 years agousertool.pl: update pager setting logic
Kyle J. McKay [Tue, 2 Mar 2021 00:21:40 +0000 (1 17:21 -0700)]
usertool.pl: update pager setting logic

Bring over the same new logic from projtool.pl that allows
some commands to disable the pager by default without completely
disallowing it.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>