openafs.git
3 years agoSynchronize NEWS with 1.8.5 03/14103/2
Benjamin Kaduk [Fri, 20 Mar 2020 16:17:13 +0000]
Synchronize NEWS with 1.8.5

Pull in all the updates to NEWS that occurred on the 1.8.x branch
in preparation for adding entries for 1.9.0.

Change-Id: I713d1576ef96793f24824f909b26da802b21ec23
Reviewed-on: https://gerrit.openafs.org/14103
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Use _IsLast to check for last call in queue 58/14158/2
Andrew Deason [Sun, 26 Apr 2020 22:26:02 +0000]
rx: Use _IsLast to check for last call in queue

Ever since commits 170dbb3c (rx: Use opr queues) and d9fc4890 (rx: Fix
test for end of call queue for LWP), rx_GetCall checks if the current
call is the last one on rx_incomingCallQueue by doing this:

    opr_queue_IsEnd(&rx_incomingCallQueue, cursor)

But opr_queue_IsEnd checks if the given pointer is the _end_ of the
last; that is, if it's the end-of-list sentinel, not an item on the
actual list. Testing for the last item in a list is what
opr_queue_IsLast is for. This is the same convention that the old Rx
queues used, but 170dbb3c just accidentally replaced queue_IsLast with
opr_queue_IsEnd (instead of opr_queue_IsLast), and d9fc4890 copied the
mistake.

So because this is inside an opr_queue_Scan loop, opr_queue_IsEnd will
never be true, so we'll never enter this block of code (unless we are
the "fcfs" thread). This means that an incoming Rx call can get stuck
in the incoming call queue, if all of the following are true:

 - The incoming call consists of more than 1 packet of incoming data.

 - The incoming call "waits" when it comes in (that is, there are no
   free threads or the service is over quota).

 - The "fcfs" thread doesn't scan the incoming call queue (because it
   is idle when the call comes in, but the relevant service is over
   quota).

To fix this, just use opr_queue_IsLast here instead of
opr_queue_IsEnd.

Change-Id: I04b90b1279f81dc518eb61e7bd450e3c0be37a77
Reviewed-on: https://gerrit.openafs.org/14158
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agotests: Give more leeway in rx/event-t 60/14160/2
Andrew Deason [Sat, 25 Apr 2020 23:21:10 +0000]
tests: Give more leeway in rx/event-t

Currently, the rx/event-t tests schedule a bunch of events up to 3
seconds in the future, and then we sleep for 3 seconds to give them a
chance to run. Since we're cutting it so close, this can rarely result
in a few events not being run (observed occasionally on FreeBSD 12.1,
where we failed to run about 3 events out of 10000).

To avoid this, just sleep for 4 seconds instead of 3. Also print out a
little more info regarding the number of fired/cancelled events, so we
can see the event count when it's wrong.

Change-Id: I6269bea2c245aeed00c129ff638423d0fa81ad23
Reviewed-on: https://gerrit.openafs.org/14160
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: fix afs_linux_mmap fstrace entry 68/14168/2
Mark Vitale [Thu, 23 Apr 2020 21:49:20 +0000]
afs: fix afs_linux_mmap fstrace entry

The format string for CM_TRACE_GMAP takes 4 substitutions, but
afs_linux_mmap only supplies 3.  This results in malformed output from
fstrace:

Type mismatch, using raw print.
Gn_map vp 0x%lx addr 0x%lx len 0x%x off 0x%x (afs / zcm)raw op
701087775, time 715.322573, pid 9644
p0:0xc0a66ec0 p1:0x8b81a000 p2:131072

Repair the recording of CM_TRACE_GMAP.

Change-Id: I2b7592e68cb42f5ae490ee8771558e5cc5a2181e
Reviewed-on: https://gerrit.openafs.org/14168
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agotests: Skip SIGBUS test on FreeBSD 45/14145/3
Andrew Deason [Mon, 13 Apr 2020 03:28:29 +0000]
tests: Skip SIGBUS test on FreeBSD

Currently, 'softsig-helper -buserror' causes a SIGBUS on most
platforms, but can result in SIGSEGV on FreeBSD by default (at least
on 11.3-RELEASE). Skip the test on FreeBSD, until we can provide a
more reliable way to generate SIGBUS.

Note that when the sysctl machdep.prot_fault_translation is set to 1,
'softsig-helper -buserror' generates a SIGBUS instead of SIGSEGV,
suggesting that generating a SIGBUS here is the old 'compat' behavior.
When machdep.prot_fault_translation is 0 (the default), the code path
in the FreeBSD kernel that dictates whether to send a SIGBUS or
SIGSEGV in this situation depends on some autodetection heuristics,
and so may produce different results depending on FreeBSD releases or
even compiler settings (due to detection of ABI based on some ELF
notes in the relevant binary).

For some details on this sysctl, see
<https://www.freebsd.org/news/status/report-2019-07-2019-09.html#Signals-delivered-on-unhandled-Page-Faults>
or the FreeBSD source code. In 11.3-RELEASE, the decision to issue a
SIGBUS or SIGSEGV can be found around sys/amd64/amd64/trap.c:355.

Change-Id: Ib75b43cc12302532ee87a3744fc364424f2a3ca6
Reviewed-on: https://gerrit.openafs.org/14145
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Avoid holding AFS_GLOCK during vinvalbuf 70/13970/5
Andrew Deason [Wed, 27 Nov 2019 05:39:24 +0000]
FBSD: Avoid holding AFS_GLOCK during vinvalbuf

Currently we call vinvalbuf(9) in a few places while holding
AFS_GLOCK, but AFS_GLOCK is a non-sleepable lock (struct mtx), and
vinvalbuf can sleep. This can trigger a panic in some rare conditions,
with the message:

    Sleeping thread (tid 100179, pid 95481) owns a non-sleepable lock

To avoid this, drop AFS_GLOCK around a few places that call
vinvalbuf().

Change-Id: I58acb144b6ffa007675402e7639b63ff3745dec5
Reviewed-on: https://gerrit.openafs.org/13970
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoafs: Fix ifdef indenting in afs_vcache.c 77/13877/5
Andrew Deason [Mon, 16 Sep 2019 04:00:26 +0000]
afs: Fix ifdef indenting in afs_vcache.c

Change-Id: Ib566156184cb3f64a0983babd5d9f7883c84cc85
Reviewed-on: https://gerrit.openafs.org/13877
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Remove MA_* abstractions 43/13843/6
Andrew Deason [Sun, 8 Sep 2019 21:10:40 +0000]
FBSD: Remove MA_* abstractions

In FBSD/osi_vnops.c, we have a few abstractions (e.g. MA_VOP_UNLOCK)
that used to expand to different things for older FreeBSD versions.
Currently, they always expand to the same thing, so just remove the
abstractions.

While we are changing these calls, also change one instance of
MA_VOP_LOCK to vn_lock (instead of VOP_LOCK), since we're not usually
supposed to call VOP_LOCK directly, according to the VOP_LOCK(9)
manpage. The MA_VOP_LOCK call was added in commit bd707fb7
(freebsd-almost-working-client-20020216), seemingly by mistake.

Change-Id: Ia0f28fe658057e87d9103a72296ab899dc762fb6
Reviewed-on: https://gerrit.openafs.org/13843
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoFBSD: Build vnode_if.h before libafs objs 83/13983/3
Tim Creech [Sat, 14 Dec 2019 03:24:57 +0000]
FBSD: Build vnode_if.h before libafs objs

Currently, if we are building with -j2 or higher, we can easily fail
to build some libafs objects because vnode_if.h does not exist yet.
vnode_if.h is generated by the FreeBSD build, but none of our objects
depend on it, so during parallel builds it may not be available by the
time we build, for example, src/external/heimdal/hcrypto/sha256.c.

This results in build errors that can look like this:

    --- sha256-kernel.o ---
cc -I. -I.. -I../nfs [...]/src/external/heimdal/hcrypto/sha256.c
    In file included from [...]/src/external/heimdal/hcrypto/sha256.c:34:
    In file included from [...]/src/crypto/hcrypto/kernel/config.h:30:
    In file included from [...]/src/afs/sysincludes.h:354:
    /usr/src/sys/sys/vnode.h:588:10: fatal error: 'vnode_if.h' file not found
    #include "vnode_if.h"
             ^~~~~~~~~~~~
    1 error generated.
    *** [sha256-kernel.o] Error code 1

    make[4]: stopped in [...]/src/libafs/MODLOAD
    1 error

To avoid this, make all of our libafs objects depends on vnode_if.h.

[adeason@dson.org: Expanded commit message.]

Change-Id: I5a7a6ece8d5fbe6cf1a5b94451c8e8ae93fdc55f
Reviewed-on: https://gerrit.openafs.org/13983
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agotests: Run perl via 'env' 44/14144/2
Andrew Deason [Mon, 13 Apr 2020 01:16:55 +0000]
tests: Run perl via 'env'

The 'perl' binary may not be /usr/bin/perl, depending on the system.
For example, on modern FreeBSD it tends to be /usr/local/bin/perl
instead.

To avoid relying on perl to be in a specific location, just run via
/usr/bin/env instead, so we pick up perl from $PATH instead.

Change-Id: Ic8dc247c82342ff79dfa80426c489ccb8e3e1450
Reviewed-on: https://gerrit.openafs.org/14144
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Remove LOCKPARENT/ISLASTCN lookup logic 78/12578/7
Tim Creech [Sun, 5 Mar 2017 23:15:58 +0000]
FBSD: Remove LOCKPARENT/ISLASTCN lookup logic

Currently, our afs_vop_lookup on FBSD tries to only lock 'dvp' for
ISDOTDOT requests when LOCKPARENT and ISLASTCN are set. There are a
couple of problems with this:

- The conditional locking logic involving LOCKPARENT/ISLASTCN is only
  relevant in very old FreeBSD releases (per-fs checking of these
  flags for parent locking went away around the FreeBSD 6 era).

- Our current logic here is wrong anyway, since we try to lock 'dvp'
  twice when those flags are set. This was mostly introduced by commit
  2f6be821 (FBSD: band-aid vnode locking in lookup), which added a
  lock/unlock pair for 'dvp' around the lock for 'vp', even though
  'dvp' was unlocked several lines earlier.

This means that if we hit the relevant code path, we will deadlock,
since we try to lock 'dvp' twice. To avoid this, just remove the
relevant logic for LOCKPARENT/ISLASTCN, since it is only relevant for
old FreeBSD releases that are not supported by us or FreeBSD.

Add and rearrange some comments around here to try to more explicitly
explain the relevant locking rules.

[adeason@dson.org: Commit message rewrite, adding comments, removing
old FreeBSD code.]

Change-Id: Iaa2c55d82c50d5a8ab42c67b0996a2b4fb6e09e6
Reviewed-on: https://gerrit.openafs.org/12578
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Remove unused 'wantparent' logic 43/14143/2
Andrew Deason [Mon, 13 Apr 2020 03:40:14 +0000]
FBSD: Remove unused 'wantparent' logic

In afs_vop_lookup, the 'wantparent' variable doesn't actually change
any logic in the function. In the if() clause that it's used, the
value of 'wantparent' is only ever used if cnp->cn_nameiop is RENAME
and ISLASTCN is set. But if both of those are true, then the second
half of the if() conditional will always be true, so the value of
'wantparent' doesn't matter.

So to remove this confusing unused logic, remove the 'wantparent'
local var, and all its associated logic.

Issue spotted by kaduk@mit.edu.

Change-Id: Ia63b88d67d21cc2b81a0c25aa31ea60ab202b0a7
Reviewed-on: https://gerrit.openafs.org/14143
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Add support for FreeBSD 11.3 92/13792/7
Andrew Deason [Mon, 19 Aug 2019 00:59:50 +0000]
FBSD: Add support for FreeBSD 11.3

Change-Id: Ibe3496f06da83a0b30182ea92081bae41fe766f3
Reviewed-on: https://gerrit.openafs.org/13792
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLINUX: Always crref after _settok_setParentPag 47/14147/2
Yadavendra Yadav [Wed, 15 Apr 2020 10:33:00 +0000]
LINUX: Always crref after _settok_setParentPag

Commit b61eac78 (Linux: setpag() may replace credentials) changed
PSetTokens2 to call crref() after _settok_setParentPag(), since
changing the parent PAG may change our credentials structure. But that
commit did not update the old pioctl PSetTokens, so -setpag
functionality remained broken on Linux for utilities that called the
old pioctl ('klog' is one such utility).

To fix this, we could copy the same code from PSetTokens2 into
PSetTokens. But instead just move this code into _settok_setParentPag
itself, to avoid code duplication. This commit also refactors
_settok_setParentPag a little to make the platform-specific ifdefs a
little easier to read through.

Change-Id: I65a165ebb1d823e690926de31b28a7728d2561b9
Reviewed-on: https://gerrit.openafs.org/14147
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLINUX: Copy session keys to parent in SetToken 46/14146/5
Yadavendra Yadav [Wed, 15 Apr 2020 10:33:00 +0000]
LINUX: Copy session keys to parent in SetToken

Commit 48589b5d (Linux: Restore aklog -setpag functionality for kernel
2.6.32+) added code to SetToken() to copy our session keyring to the
parent process, in order to implement -setpag functionality. But this
was removed from SetToken() in commit 1a6d4c16 (Linux: fix aklog
-setpag to work with ktc_SetTokenEx), when the same code was moved to
ktc_SetTokenEx().

Add this code back to SetTokens(), so -setpag functionality can work
again with utilities that use older functions like ktc_SetToken, like
'klog'.

Change-Id: I68c9bf2e19783ea6f84b4c5ebf2ef188d1d8d6ad
Reviewed-on: https://gerrit.openafs.org/14146
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoredhat: add make to the build requirements 19/14119/3
Michael Meffie [Fri, 20 Mar 2020 22:17:56 +0000]
redhat: add make to the build requirements

`make` is not necessarily installed, even if when all the other build
requirements are installed.

Add `make` to the list build requirements to complete the build
requirements. With this change it is possible to build the packages
after running the `yum-builddep` to install all of the needed build
requirements.

Change-Id: I032ba1f23d08468c5e21edc5662b20cc9498d1c9
Reviewed-on: https://gerrit.openafs.org/14119
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agovlserver: Correctly pad nvlentry for "O" RPCs 39/14139/2
Andrew Deason [Tue, 7 Apr 2020 18:15:31 +0000]
vlserver: Correctly pad nvlentry for "O" RPCs

For our old-style "O" RPCs (e.g. VL_CreateEntry, instead of
VL_CreateEntryN), vlserver calls vldbentry_to_vlentry to convert to
the internal 'struct nvlentry' format. After all of the sites have
been copied to the internal format, we fill the remaining sites by
setting the serverNumber to BADSERVERID. For nvldbentry_to_vlentry, we
do this for NMAXNSERVERS sites, but for vldbentry_to_vlentry, we do
this for OMAXNSERVERS.

The thing is, both functions are filling in entries for a 'struct
nvlentry', which has NMAXNSERVERS 'serverNumber' entries. So for
vldbentry_to_vlentry, we are skipping setting the last few sites
(specifically, NMAXNSERVERS-OMAXNSERVERS = 13-8 = 5).

This can easily cause our O-style RPCs to write out entries to disk
that have uninitialized sites at the end of the array. For example, an
entry with one site should have server numbers that look like this:

    serverNumber = {1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}

That is, one real serverid (a '1' here), followed by twelve
BADSERVERIDs.

But for a VL_CreateEntry call, the 'struct nvlentry' is zeroed out
before vldbentry_to_vlentry is called, and so the server numbers in
the written entry look like this:

    serverNumber = {1, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0}

That is, one real serverid (a '1' here), followed by seven
BADSERVERIDs, followed by five '0's.

Most of the time, this is not noticeable, since our code that reads in
entries from disk stops processing sites when we encounter the first
BADSERVERID site (see vlentry_to_nvldbentry). However, if the entry
has 8 sites, then none of the entries will contain BADSERVERID, and so
we will actually process the trailing 5 bogus sites. This would appear
as 5 extra volume sites for a volume, most likely all for the same
server.

For VL_CreateEntry, the vlentry struct is always zeroed before we use
it, so the trailing sites will always be filled with 0. For
VL_ReplaceEntry, the trailing sites will be unchanged from whatever
was read in from the existing disk entry.

To fix this, just change the relevant loop to go through NMAXNSERVERS
entries, so we actually go to the end of the serverNumber (et al)
array.

This may appear similar to commit ddf7d2a7 (vlserver: initialize
nvlentry elements after read). However, that commit fixed a case
involving the old vldb database format (which hopefully is not being
used). This commit fixes a case where we are using the new vldb
database format, but with the old RPCs, which may still be used by old
tools.

Change-Id: Ic6882d1452963ca93403748917c313068acfdaab
Reviewed-on: https://gerrit.openafs.org/14139
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoredhat: fix rpmbuild warnings 18/14118/3
Michael Meffie [Fri, 20 Mar 2020 21:53:22 +0000]
redhat: fix rpmbuild warnings

Fix warnings issued by recent versions of rpmbuild:

    warning: Macro expanded in comment on line 110: %{afsvers}/...
    warning: extra tokens at the end of %endif directive in line 1469:
             %endif  # build_userspace
    warning: line 331: It's not recommended to have unversioned Obsoletes:
             Obsoletes: openafs-client-compat

The first two warnings are just issues with comments, which apparently
are not completely ignored by rpmbuild.  The third issue is a warning
about an unversioned "Obsoletes" directive. Remove the old Obsoletes for
openafs-client-compat, which was obsoleted no later than the 1.4.x
series (more than 10 years ago).

While here clean up the spec by removing the old cvs $Revsion$ keyword
from the comments at the top of the file, and removing an old commented
out setup directive.

Change-Id: I8d7a050ea6a0cc7a2d9a6af9a91d25ce545586e7
Reviewed-on: https://gerrit.openafs.org/14118
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoopr: Allow non-2^x for n_buckets in opr_cache_init 22/14122/3
Andrew Deason [Mon, 30 Mar 2020 19:21:21 +0000]
opr: Allow non-2^x for n_buckets in opr_cache_init

Currently, opr_cache_init requires that opts->n_buckets is a power of
2 (since our underlying opr_dict requires this). However, callers may
want to pick a number of buckets based on some other value. Requiring
each caller to calculate the nearest power-of-2 is annoying, so
instead just have opr_cache_init itself calculate a nearby power of 2.

That is, with this commit, opts->n_buckets is allowed to not be a
power of 2; when it's not a power of 2, opr_cache_init will calculate
the next highest power of 2 and use that as the number of buckets.

Change-Id: Icd3c56c1fe0733e3dac964ea9a98ff7b436254e6
Reviewed-on: https://gerrit.openafs.org/14122
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agolibafs: Serialize INSTDIRS/DESTDIRS and COMPDIRS 37/14137/2
Andrew Deason [Sun, 5 Apr 2020 21:29:52 +0000]
libafs: Serialize INSTDIRS/DESTDIRS and COMPDIRS

Our libafs build logic involves a few targets that 'cd' into a
per-kernel subdir: notably INSTDIRS and DESTDIRS (the targets to 'make
install' or 'make dest' our kernel modules) and COMPDIRS (the target
to setup/build the kernel module).

Both of these potentially 'cd' into a subdirectory (e.g. MODLOAD64),
and run some make rules. Since INSTDIRS and COMPDIRS are different
targets and don't depend on each other for many platforms, running
those rules can happen in parallel. After they 'cd' into the relevant
dir, they run a new 'make' in a subshell, and so underlying rules for
building e.g. AFS_component_version_number.c are not serialized.

So for a parallel build on, say, Solaris, we can encounter errors when
two sub-makes try to make AFS_component_version_number.c at the same
time, which looks something like this (with various lines output from
other sub-processes mixed in):

    cd src && cd sys && gmake install
    gmake[3]: Leaving directory '/[...]/src/libuafs'
    rm -f AFS_component_version_number.c.NEW
    /opt/developerstudio12.6/bin/cc [...] -D_KERNEL -DSYSV -dn -m64 -xmodel=kernel -xvector=%none -xregs=no%float  -Wu,-save_args  -o AFS_component_version_number.o -c AFS_component_version_number.c
    mv: cannot access AFS_component_version_number.c.NEW
    gmake[4]: *** [/[...]/src/config/Makefile.version:13: AFS_component_version_number.c] Error 2
    gmake[4]: Leaving directory '/[...]/src/libafs/MODLOAD64'
    gmake[3]: *** [Makefile:85: solaris_instdirs] Error 2
    gmake[3]: *** Waiting for unfinished jobs....

To avoid this, just make INSTDIRS and DESTDIRS depend on COMPDIRS, so
we can make sure they don't run at the same time.

Change-Id: I2510e1894c44dd0864cf2eab5613b805342b6718
Reviewed-on: https://gerrit.openafs.org/14137
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agobutc: rename local var tapeblocks to numTapeblocks 28/14128/3
Cheyenne Wills [Wed, 1 Apr 2020 15:38:05 +0000]
butc: rename local var tapeblocks to numTapeblocks

The local variable tapeblocks in GetConfigParams matches a global
variable.  Rename the local variable to avoid confusion with the global
name.

Change-Id: I1c30433696a35a74978ef0c23881c82054b416c5
Reviewed-on: https://gerrit.openafs.org/14128
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agobuild: remove unused LINUX_PKGREL from configure.ac 17/14117/2
Michael Meffie [Mon, 23 Mar 2020 13:46:05 +0000]
build: remove unused LINUX_PKGREL from configure.ac

This change removes the unused LINUX_PKGREL definition from the
configure.ac file.

Commit 6a27e228bac196abada96f34ca9cd57f32e31f5c converted the setting of
the RPM package version and release values in the openafs.spec file from
autoconf to the makesrpm.pl script. That commit left LINUX_PKGREL in
configure.ac because it was still referenced by the Debian packaging,
which was still in-tree at that time.

Commit ada9dba0756450993a8e57c05ddbcae7d1891582 removed the last trace
of the Debian packaging, but missed the removal of the LINUX_PKGREL.

Change-Id: I17aeccdb38078faa413f2cd3a935b43238982606
Reviewed-on: https://gerrit.openafs.org/14117
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agovos: Print "done" in non-verbose 'vos remsite' 27/14127/2
Andrew Deason [Thu, 2 Apr 2020 03:59:38 +0000]
vos: Print "done" in non-verbose 'vos remsite'

Currently, 'vos remsite' always prints the message "Deleting the
replication site for volume %lu ...", and then calls VDONE if the
operation is successful. VDONE prints the trailing "done", but only if
-verbose is turned on, and so if -verbose is not specified, the output
of 'vos remsite' looks broken:

    $ vos remsite fs1 vicepa vol.foo
    Deleting the replication site for volume 1234 ...Removed replication site fs1 /vicepa for volume vol.foo

To fix this, unconditionally print the trailing "done", instead of
going through VDONE, so 'vos remsite' output now looks like this:

    $ vos remsite fs1 vicepa vol.foo
    Deleting the replication site for volume 1234 ... done
    Removed replication site fs1 /vicepa for volume vol.foo

Change-Id: I0b42f4cb9b695331bf047243bf6ae4a1cdbb89c4
Reviewed-on: https://gerrit.openafs.org/14127
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoAvoid duplicate definitions of globals 06/14106/4
Cheyenne Wills [Wed, 1 Apr 2020 15:48:57 +0000]
Avoid duplicate definitions of globals

GCC 10 changed a default flag from -fcommon to -fno-common.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678 for some background.

The change in gcc 10 results in build link-time errors. For example:
   ../../src/xstat/.libs/liboafs_xstat_cm.a(xstat_cm.o):(.bss+0x2050):
       multiple definition of `numCollections';

Ensure that only one definition for global data objects exist and change
references to use "extern" as needed.

To ensure that future changes do not introduce duplicated global
definitions, add the -fno-common flag to XCFLAGS when using the
configure --enable-checking setting.

Change-Id: I6780dd995fe6fb6c2102765ff3484c18e1e1cd58
Reviewed-on: https://gerrit.openafs.org/14106
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agovos: Properly print volume transaction flags 26/14126/3
Andrew Deason [Wed, 1 Apr 2020 02:19:18 +0000]
vos: Properly print volume transaction flags

Currently, the code in 'vos status' treats the 'iflags' and 'vflags'
of a transaction like an enumerated type; that is, we only check if
'iflags' is equal to ITOffline or ITBusy, etc. But both of these flags
fields are bitfields; any combination of the relevant flags could
theoretically be set.

Practically speaking, we only ever set at most one of the flags in
'iflags', but if anything ever did set more than one flag, our output
would look broken (we'd print "attachFlags:" without any flags).

For 'vflags', multiple flags are often set at once: the most common
combination is VTDeleteOnSalvage|VTOutOfService. So currently, we
usually print "attachFlags:" without any actual flags, since the
'vflags' field isn't exactly equal to VTDeleteOnSalvage (instead it's
set to VTDeleteOnSalvage|VTOutOfService). And if we ever did see just
VTDeleteOnSalvage set by itself, the way the switch() cases fall
through to each other, we'd print out that _all_ flags are set.

To fix all of this, just test for the individual flag bits instead.

Change-Id: Ib4d207bc713f0ef8eb51b9dbeaf2af50395536ee
Reviewed-on: https://gerrit.openafs.org/14126
Tested-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLINUX: Introduce afs_d_path 21/13721/3
Andrew Deason [Tue, 23 Jul 2019 18:50:31 +0000]
LINUX: Introduce afs_d_path

Move our preprocessor logic around d_path into an osi_compat.h
wrapper, called afs_d_path. This just makes it a little easier to use
d_path, and moves a tiny bit of #ifdef cruft away from real code.

Change-Id: I2032eda3fef18be6e77e3bf362ec5ce641e1d76d
Reviewed-on: https://gerrit.openafs.org/13721
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoafs: Detect VIOCPREFETCH special case properly 01/13301/6
Andrew Deason [Fri, 24 Aug 2018 18:03:24 +0000]
afs: Detect VIOCPREFETCH special case properly

Currently, afs_syscall_pioctl handles the VIOCPREFETCH pioctl as a
special case, calling into a different code path to handle
backgrounding the prefetch operation. However, we detect that we're
handling a VIOCPREFETCH operation just by looking at the lower 8 bits
of the given opcode. This means that any pioctl that ends in 0x0F will
trigger this codepath, such as if we add a 'C' or 'O' pioctl that uses
code 0x0F.

We only want to catch VIOCPREFETCH requests for this code path, so fix
the check to also check if we're processing a 'V' pioctl.

Change-Id: Ica8c2364f96aa3c8b4d2213bebd9a1e4cb6fa730
Reviewed-on: https://gerrit.openafs.org/13301
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agotests: Wait for server start in auth/superuser-t 09/14109/4
Andrew Deason [Tue, 24 Mar 2020 16:59:48 +0000]
tests: Wait for server start in auth/superuser-t

The auth/superuser-t test runs an Rx server and client in two child
processes. If the client process tries to contact the server before
the server has started listening on its port, some tests involving
RPCs can fail (notably test 39, "Can run a simple RPC").

Normally if we try to contact a server that's not there, Rx will try
resending its packets a few times, but on Linux with AFS_RXERRQ_ENV,
if the port isn't open at all, we can get an ICMP_PORT_UNREACH error,
which causes the relevant Rx call to die immediately with
RX_CALL_DEAD.

This means that if the auth/superuser-t client is only just a bit
faster than the server starting up, tests can fail, since the server's
port is not open yet.

To avoid this, we can wait until the server's port is open before
starting the client process. To do this, have the server process send
a SIGUSR1 to the parent after rx_Init() is called, and have the parent
process wait for the SIGUSR1 (waiting for a max of 5 seconds before
failing). This should guarantee that the server's port will be open by
the time the client starts running.

Note that before commit 086d1858 (LINUX: Include linux/time.h for
linux/errqueue.h), AFS_RXERRQ_ENV was mistakenly disabled on Linux
3.17+, so this issue was probably not possible on recent Linux before
that commit.

Change-Id: I0032a640b83c24f72c03e7bea100df5bc3d9ed4c
Reviewed-on: https://gerrit.openafs.org/14109
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>

4 years agoLINUX: Clear lock 'pid' fields with NULL 08/14108/2
Andrew Deason [Tue, 24 Mar 2020 16:34:51 +0000]
LINUX: Clear lock 'pid' fields with NULL

Currently, when we release a lock, we set the e.g. pid_writer field to
0, to clear out any previous pid that was set. On Linux, the
pid_writer field is a pointer, and sparse(1) complains about using a
plain integer 0 in this way:

      CHECK   [...]/afs_axscache.c
    [...]/afs_axscache.c:24:19: warning: Using plain integer as NULL pointer
    [...]/afs_axscache.c:68:9: warning: Using plain integer as NULL pointer
    [...]/afs_axscache.c:88:5: warning: Using plain integer as NULL pointer
    [...]/afs_axscache.c:111:13: warning: Using plain integer as NULL pointer
    [...]/afs_axscache.c:121:17: warning: Using plain integer as NULL pointer
    [...]/afs_axscache.c:126:17: warning: Using plain integer as NULL pointer
    [...]/afs_axscache.c:154:13: warning: Using plain integer as NULL pointer
    [...]/afs_axscache.c:165:9: warning: Using plain integer as NULL pointer

This doesn't break anything, but it spews out quite a lot of warnings
when building with sparse(1) available. To just reduce this noise a
bit, assign these fields to actual NULL.

Since some other platforms do use a plain integer in these fields
(they are an actual pid), define 'MyPid_NULL' to use '0' or 'NULL'
depending on the platform. Define MyPid_NULL to NULL only on Linux;
this causes us to still assign 0 to a pointer on some platforms, but
Linux is the only one that complains, so only bother using NULL on
Linux for now.

Change-Id: I35fcb896ceaa346c330622cfc2913b2975295836
Reviewed-on: https://gerrit.openafs.org/14108
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agorxgen: Properly generate brief union default arm 07/14107/2
Andrew Deason [Tue, 10 Mar 2020 21:05:47 +0000]
rxgen: Properly generate brief union default arm

Commit 13ae3de3 (Add "brief" option to rxgen) added the -b option to
rxgen, which (among other things) makes rxgen stop including the name
of an RPC-L union type within its fields. That is, instead of this:

    struct foo_type {
        afs_int32 foo_tag;
        union {
            /* ... */
        } foo_type_u;
    };

rxgen -b generates this:

    struct foo_type {
        afs_int32 foo_tag;
        union {
            /* ... */
        } u;
    };

And all of the autogenerated XDR code is altered to use the 'u' field
instead of foo_type_u. However, if a 'default:' arm is defined in the
definition for the RPC-L union, the autogenerated XDR code still tries
to reference the non-brief name (e.g. foo_type_u). This causes a build
failure when actually trying to compile the generated .xdr.c, like so:

    foo.xdr.c:809:39: error: 'foo_type' has no member named 'foo_type_u'
        if (!xdr_bytes(xdrs, (char **)&objp->foo_type_u.xxx, &__len, FOO_MAX)) {
                                           ^
    foo.xdr.c:812:11: error: 'foo_type' has no member named 'foo_type_u'
        *(&objp->foo_type_u.xxx) = __len;

This happens because the portion of emit_union() that generates the
XDR code for the default arm wasn't updated to use a different
formatting string when 'brief_flag' is set, like the rest of
emit_union.

To fix this, just check for brief_flag and use 'briefformat'
accordingly, like the other code that checks for brief_flag.

Currently nothing in the tree uses the default arm of RPC-L unions
with 'rxgen -b', but external callers could, or our future code may do
so.

Change-Id: Ifcebfc48a3a64c68fee12ba0d177ae19b0956c58
Reviewed-on: https://gerrit.openafs.org/14107
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoubik: death to SVOTE_GetSyncSite 43/14043/10
Marcio Barbosa [Thu, 27 Feb 2020 22:28:14 +0000]
ubik: death to SVOTE_GetSyncSite

The SVOTE_GetSyncSite RPC was intended to provide the IP address of the
current sync-site. Unfortunately, the RPC-L incorrectly defined ahost as
an input argument instead of an output argument. As a result, the IP
address in question is not returned to the callers of SVOTE_GetSyncSite.
Moreover, calls to this RPC must be made through connections associated
with the VOTE_SERVICE_ID. Sadly, the ubik_Call* functions call
SVOTE_GetSyncSite using connections associated with the USER_SERVICE_ID.
Consequently, the server getting this request returns RXGEN_OPCODE,
meaning that this RPC is not implemented by the service in question.

Since RPC arguments cannot be changed without causing compatibility
issues between different client / server versions and the RPC in
question is being called through the wrong service id, remove
SVOTE_GetSyncSite and its callers. Considering that in all versions of
OpenAFS calls to this RPC always return RXGEN_OPCODE, no behavior
change is introduced by this commit.

Also, remove the "chaseCount logic" from the ubik_Call* functions.
This logic prevents the loop counter from being moved backwards
indefinitely, resulting in an infinite loop. Fortunately, without the
VOTE_GetSyncSite() calls this counter cannot be moved backwards more
than once.

Change-Id: Idd071583e8f67109e003f7a5675de02a235e5809
Reviewed-on: https://gerrit.openafs.org/14043
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agotests: Add cache-t to .gitignore in tests/opr 02/14102/2
Cheyenne Wills [Fri, 20 Mar 2020 18:03:48 +0000]
tests: Add cache-t to .gitignore in tests/opr

Commit 48fbb45 (opr: Introduce opr_cache) added a new test (cache-t),
but did not update the .gitignore file for it.

Change-Id: I6de6130257a62f495ac942c05937eb109ce84a75
Reviewed-on: https://gerrit.openafs.org/14102
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agotests: Add core to .gitignore in tests 01/14101/2
Cheyenne Wills [Fri, 20 Mar 2020 17:54:23 +0000]
tests: Add core to .gitignore in tests

opr/softsig-t can produce a core file as part of its test.

Change-Id: I3bc7e587151e5915038e31887018889a7ffa6993
Reviewed-on: https://gerrit.openafs.org/14101
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agovos: take RO volume offline during convertROtoRW 66/14066/2
Marcio Barbosa [Thu, 13 Feb 2020 03:39:00 +0000]
vos: take RO volume offline during convertROtoRW

The vos convertROtoRW command converts a RO volume into a RW volume.
Unfortunately, the RO volume in question is not set as "out of service"
during this process. As a result, accesses to the volume being converted
can leave volume objects in an inconsistent state.

Consider the following scenario:

1. Create a volume on host_b and add replicas on host_a and host_b.

$ vos create host_b a vol_1
$ vos addsite host_b a vol_1
$ vos addiste host_a a vol_1

2. Mount the volume:

$ fs mkmount /afs/.mycell/vol_1 vol_1
$ vos release vol_1
$ vos release root.cell

3. Shutdown dafs on host_b:

$ bos shutdown host_b dafs

4. Remove RO reference to host_b from the vldb:

$ vos remsite host_b a vol_1

5. Attach the RO copy by touching it:

$ fs flushall
$ ls /afs/mycell/vol_1

6. Convert RO copy to RW:

$ vos convertROtoRW host_a a vol_1

Notice that FSYNC_com_VolDone fails silently (FSYNC_BAD_STATE), leaving
the volume object for the RO copy set as VOL_STATE_ATTACHED (on success,
this volume should be set as VOL_STATE_DELETED).

7. Add replica on host_a:

$ vos addsite host_a a vol_1

8. Wait until the "inUse" flag of the RO entry is cleared (or force this
to happen by attaching multiple volumes).

9. Release the volume:

$ vos release vol_1

Failed to start transaction on volume 536870922
Volume not attached, does not exist, or not on line
Error in vos release command.
Volume not attached, does not exist, or not on line

To fix this problem, take the RO volume offline during the vos
convertROtoRW operation.

Change-Id: I1e417a026ed819fab4435e8992311fcd4f339341
Reviewed-on: https://gerrit.openafs.org/14066
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agovol: fix namei_ConvertROtoRWvolume return code 65/14065/3
Marcio Barbosa [Fri, 6 Mar 2020 15:15:38 +0000]
vol: fix namei_ConvertROtoRWvolume return code

Commit 8632f23d6718a3cd621791e82d1cf6ead8690978 introduced checks for
the return value of snprintf calls in namei_ops. On success, the value
returned by this function represents the number of written characters.
Unfortunately, the variable used to store this value is the same
variable that represents the status code returned by
namei_ConvertROtoRWvolume. Consequently, a successful execution of
namei_ConvertROtoRWvolume results in a status code different the 0 (and
equal to the number of written characters).

To fix this problem, set the status code in question back to 0 after a
successful execution of namei_ConvertROtoRWvolume.

Change-Id: Ic6fd6483f8d94fd64587f8bae249b9d911d846b4
Reviewed-on: https://gerrit.openafs.org/14065
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoafs: Clean up compiler warning casting ptr to int 92/14092/4
Cheyenne Wills [Fri, 6 Mar 2020 17:00:25 +0000]
afs: Clean up compiler warning casting ptr to int

In osi_probe.c, the macro 'check_result' casts a pointer to an int which
on older Linux kernels (e.g. 2.6.18) produces several lines with the C
warning:

... warning: cast from pointer to integer of different size

Change the cast from int to long int.

Linux 2.6.18 doesn't provide intptr_t or uintptr_t, and stdint.h is not
available to kernel modules.  But the size of a pointer is the size of a
long (see uintptr_t in linux/types.h - Linux 2.6.24+), so
change the cast from int to long.

Note that the this code by default only gets pulled in for older Linux
kernels (e.g. 2.6.18).  For newer kernels, ENABLE_LINUX_SYSCALL_PROBING
is not defined, and so most of osi_probe.c is not built.

Change-Id: If1b41e11c46f4a14ff5127ed4d602485645ddf2a
Reviewed-on: https://gerrit.openafs.org/14092
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

4 years agoLINUX: Properly revert creds in osi_UFSTruncate 98/14098/2
Andrew Deason [Fri, 13 Mar 2020 18:00:35 +0000]
LINUX: Properly revert creds in osi_UFSTruncate

Commit cd3221d3 (Linux: use override_creds when available) caused us
to force the current process's creds to the creds of afsd during
osi_file.c file ops, to avoid access errors in some cases.

However, in osi_UFSTruncate, one code path was missed to revert our
creds back to the original user's creds: when the afs_osi_Stat call
fails or deems the truncate unnecessary. In this case, the calling
process keeps the creds for afsd after osi_UFSTruncate returns,
causing our subsequent access-checking code to think that the current
process is in the same context as afsd (typically uid 0 without a
pag).

This can cause the calling process to appear to transiently have the
same access as non-pag uid 0; typically this will be unauthenticated
access, but could be authenticated if uid 0 has tokens.

To fix this, modify the early return in osi_UFSTruncate to go through
a 'goto done' destructor instead, and make sure we revert our creds in
that destructor.

Thanks to cwills@sinenomine.net for finding and helping reproduce the
issue.

Change-Id: I6820af675edcb7aa00542ba40fc52430d68c05e8
Reviewed-on: https://gerrit.openafs.org/14098
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Jeffrey Hutzelman <jhutz@cmu.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: Cheyenne Wills <cwills@sinenomine.net>

4 years agotests: Run more manpage tests by default 73/14073/3
Andrew Deason [Thu, 20 Feb 2020 14:37:28 +0000]
tests: Run more manpage tests by default

Ever since commit f0774acd (Introduce TAP tests of man pages for
command_subcommand), we've had tests to check that we have man pages
for every subcommand in a command suite. This was done for several
command suites, including 'bos', and 'fs', but the bos and fs tests were
never added to the TESTS file.

Add them, so the tests run by default in a 'make check'. Fortunately,
the tests still pass today.

Change-Id: I90c006845d054fa3e795203bb1deff675e558622
Reviewed-on: https://gerrit.openafs.org/14073
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoubik: Rename flags to dbFlags 64/13864/4
Andrew Deason [Thu, 12 Sep 2019 19:36:04 +0000]
ubik: Rename flags to dbFlags

Rename ubik_dbase->flags to ubik_dbase->dbFlags, to make it easier to
distinguish between other fields and variables just called 'flags'.

Change-Id: I17258f9a65e989943d066307e332550d66ca7500
Reviewed-on: https://gerrit.openafs.org/13864
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoubik: Clarify UBIK_VERSION_LOCK semantics 63/13863/4
Andrew Deason [Thu, 12 Sep 2019 17:37:04 +0000]
ubik: Clarify UBIK_VERSION_LOCK semantics

Commit e4ac552a (ubik: Introduce version lock) added UBIK_VERSION_LOCK
and version_data. The commit message mentions that holding either
UBIK_VERSION_LOCK or DBHOLD is enough to be able to read the protected
items and both locks must be held to modify them, but this isn't
mentioned in the actual code.

Add a comment explaining these locking rules, to make these rules
clearer to readers.

Change-Id: I715f89695add6d94e13d6ee1dc6addd1e748d3fd
Reviewed-on: https://gerrit.openafs.org/13863
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoLINUX: Include linux/time.h for linux/errqueue.h 50/13950/3
Cheyenne Wills [Wed, 20 Nov 2019 19:43:03 +0000]
LINUX: Include linux/time.h for linux/errqueue.h

The configuration test for errqueue.h fails with an undefined structure
error on a Linux 3.17 (or higher) system.  This prevents setting
HAVE_LINUX_ERRQUEUE_H, which is used to define AFS_RXERRQ_ENV.

Linux commit f24b9be5957b38bb420b838115040dc2031b7d0c (net-timestamp:
extend SCM_TIMESTAMPING ancillary data struct) - which was picked up in
linux 3.17 added a structure that uses the timespec structure.  After
this commit, we need to include linux/time.h to pull in the definition
of the timespec struct.

Change-Id: Ifab79f8454c771276d5fdf443c4d68400b70134a
Reviewed-on: https://gerrit.openafs.org/13950
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoubik: Log urecovery_CheckTid-aborted txes 62/13862/3
Andrew Deason [Wed, 11 Sep 2019 21:42:47 +0000]
ubik: Log urecovery_CheckTid-aborted txes

Log when urecovery_CheckTid aborts/ends a running remote transaction.
This is usually a rare event, occurring when some ubik sites get
"stuck" or confused about the state of the quorum. Logging some
details when this happens can be useful when investigating issues
post-mortem, or just to see why a transaction failed.

Change-Id: If0a7cd134aaac3722fe7214a1d8f0efab550ad11
Reviewed-on: https://gerrit.openafs.org/13862
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoubik: Introduce ubik_CallRock 87/13987/15
Andrew Deason [Fri, 23 Aug 2019 17:21:54 +0000]
ubik: Introduce ubik_CallRock

In OpenAFS 1.0, the way we made dbserver RPC calls was to pass the
relevant RPC and arguments to ubik_Call()/ubik_Call_New(), which
coerced all of the RPC arguments into 'long's. To make this more
typesafe, in commit 4478d3a9 (ubik-call-sucks-20060703) most callers
were converted to use ubik_RPC_name()-style calls, which used
functions autogenerated by rxgen.

This latter approach, however, only lets us use the ubik_Call-style
site selection code with RPCs processed by rxgen; we can't insert
additional code to run before or after the relevant RPC.

To make our dbserver calls more flexible, but avoid coercing all of
our arguments into 'long's again, move back to the ubik_Call()-style
approach, but use actual typed arguments with a callback function and
a rock. Call it ubik_CallRock().

With this commit rxgen still generates the ubik_RPC_name()-style
stubs, but the stubs just call ubik_CallRock with a generated callback
function, instead of spitting out the equivalent of ubik_Call() in the
generated code itself.

To try to ensure that this commit doesn't incur any unintended extra
changes, make ubik_CallRock consist of the generated code that was
inside rxgen before this commit. This is almost identical to
ubik_Call, but not quite; consolidating these two functions can happen
in a future commit if desired.

Change-Id: I0c3936e67a40e311bff32110b2c80696414b52d4
Reviewed-on: https://gerrit.openafs.org/13987
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLINUX 5.6: define time_t and use timespec/timespec64 83/14083/7
Cheyenne Wills [Tue, 3 Mar 2020 22:39:49 +0000]
LINUX 5.6: define time_t and use timespec/timespec64

The time_t type and the structure timeval were removed for use in kernel
space code in Linux commits:
    412c53a680a97cb1ae2c0ab60230e193bee86387
        y2038: remove unused time32 interfaces
    c766d1472c70d25ad475cf56042af1652e792b23
        y2038: hide timeval/timespec/itimerval/itimerspec types

Add an autoconf test for the time_t type.

If time_t is missing, define the time_t type when building the kernel
module.

Change the vattr structure in LINUX/osi_vfs.h to use timespec/timespec64
instead of the timeval structure.

Conditionalize the definition of gettimeofday (needed by rand-fortuna.c) in
crypto/hcrypto/kernel/config.h.  It is unused by the Linux kernel module
and the function uses struct timeval that is no longer available.

Change-Id: Idc9a1ded748f833d804164d29c49c9aee26ae8f5
Reviewed-on: https://gerrit.openafs.org/14083
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLINUX: Avoid building rand-fortuna-kernel.o 84/14084/3
Andrew Deason [Mon, 2 Mar 2020 22:17:55 +0000]
LINUX: Avoid building rand-fortuna-kernel.o

Currently, we build rand-fortuna-kernel.o for libafs on all platforms,
even though we only use the fortuna RNG on AIX, DragonFlyBSD, HP-UX,
and Irix. Everywhere else, our RAND_bytes() in
src/crypto/hcrypto/kernel/rand.c uses osi_readRandom() instead of
going through heimdal.

Building rand-fortuna.c causes occasional build headaches for the
kernel on Linux (see cc7f942, "LINUX: Disable kernel fortuna large
frame errors"). The most recent instance of this is that Linux 5.6
removes the definition for struct timeval, which is referenced in
rand-fortuna.c.

The Linux kernel is constantly changing, and so trying to keep
rand-fortuna.c building on Linux seems like a waste of ongoing effort.
So, just stop building rand-fortuna-kernel.o on Linux. The original
intent of building this file on all platforms was to avoid bitrot, so
still keep building rand-fortuna-kernel.o on all other platforms even
when it's not used; just avoid it on Linux specifically, the platform
that requires the most effort.

To accomplish this, move rand-fortuna-kernel.o from AFSAOBJS to
AFS_OS_OBJS, and remove it from the Linux-only AFSPAGOBJS.

Also remove our configure tests for -Wno-error=frame-larger-than=,
since they're no longer used by anything.

Change-Id: I0d5f14f9f6ba2bdd7391391180d32383b4da89ed
Reviewed-on: https://gerrit.openafs.org/14084
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoopr: Introduce opr_cache 84/13884/11
Andrew Deason [Fri, 20 Sep 2019 19:19:23 +0000]
opr: Introduce opr_cache

Add a simple general-purpose in-memory cache implementation, called
opr_cache. Keys and values are simple flat opaque buffers (no complex
nested structures allowed), hashing is done with jhash, and cache
eviction is mostly random with some LRU bias.

Partly based off a different implementation by
mbarbosa@sinenomine.net.

Change-Id: I16b5988947ff603dfe31613cd7be3908a69264e5
Reviewed-on: https://gerrit.openafs.org/13884
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: Properly type afs_osi_suser cred arg 85/14085/3
Andrew Deason [Tue, 14 Jan 2020 16:51:42 +0000]
afs: Properly type afs_osi_suser cred arg

Currently, afs_osi_suser is declared with a void* argument, even
though its only argument is always effectively a afs_ucred_t*. This
allows us to call afs_osi_suser with any pointer type without the
compiler complaining. Currently, some callers call afs_osi_suser with
an incorrectly-typed afs_ucred_t** instead, like so:

    func(afs_ucred_t **credpp)
    {
        afs_ucred_t **acred = *acredpp; /* incorrect assignment */
        if (afs_osi_suser(acred)) {
            /* ... */
        }
    }

The actual code in the tree hides this to some degree behind various
function calls and layers of indirection (e.g. afs_suser()), but this
is effectively what we do. This causes compiler warnings because we
are doing incorrect pointer assignments, but the end result works
because afs_osi_suser actually uses an afs_ucred_t*.

The type confusion makes it very easy to accidentally give the wrong
type to afs_osi_suser. This only really matters on SOLARIS, since that
is the only platform that actually uses its argument to
afs_osi_suser().

To fix all of this, just declare afs_osi_suser as taking an
afs_ucred_t*, and fix all of the relevant functions to handle the
right type.

Change-Id: I1366aedf0f3d7689735a9424c5272233931e3bf2
Reviewed-on: https://gerrit.openafs.org/14085
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLINUX: Initialize CellLRU during osi_Init 93/14093/9
Yadavendra Yadav [Thu, 5 Mar 2020 07:21:55 +0000]
LINUX: Initialize CellLRU during osi_Init

When OpenAFS kernel module gets loaded, it will create certain entries
in "proc" filesystem. One of those entries is "CellServDB", in case
we read "/proc/fs/openafs/CellServDB" without starting "afsd" it will
result in crash with NULL pointer deref. The reason for crash is
CellLRU has not been initialized yet (since "afsd" is not started)
i.e afs_CellInit is not yet called, because of this "next" and "prev"
pointers will be NULL. Inside "c_start()" we do not check for NULL
pointer while traversing CellLRU and this causes crash.

To avoid this initialize CellLRU during module intialization.

Change-Id: I21cbc0e016b384f0ab456c05087384b6ed986b0d
Reviewed-on: https://gerrit.openafs.org/14093
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoCleanup vestiges of old shared library build directories 45/14045/2
Michael Meffie [Fri, 24 Jan 2020 18:40:28 +0000]
Cleanup vestiges of old shared library build directories

Remove traces of the old shlibrpc and shlibafsauthent build directories,
which are no longer needed since the conversion to libtool for building
shared libraries.

Change-Id: I8dbfdf9908b4a5527470b7cb4b969e7a160cdd51
Reviewed-on: https://gerrit.openafs.org/14045
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agodoc: Replace src/SOURCE-MAP with src/README.md 03/14003/6
Michael Meffie [Thu, 12 Dec 2019 20:58:32 +0000]
doc: Replace src/SOURCE-MAP with src/README.md

Replace the old and poorly maintained "SOURCE-MAP" file with a markdown
formatted README.md file.  Try to organize the directories in sections
to hopefully make a more useful guide to the source code and build
directories.

Thanks to Cheyenne Wills and Benjamin Kaduk for suggestions.

Change-Id: I50f58aa99453bc3412b60a7591d6957cfa83b5b1
Reviewed-on: https://gerrit.openafs.org/14003
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoauth: accept a NULL afsconf_dir in afsconf_SetCellInfo again 61/14061/9
Michael Meffie [Fri, 21 Feb 2020 15:08:42 +0000]
auth: accept a NULL afsconf_dir in afsconf_SetCellInfo again

Commit 93b26c6f55245e2187e574eb928f5e0ce66a245e added the cellservDB
field to the afsconf_dir structure to track the CellServDB pathname.
This commit also changed the afsconf_SetCellInfo() and
afsconf_SetExtendedCellInfo() functions to use the new cellservDB member
to open the CellServDB file.

Unfortunately, the bosserver intentionally calls afsconf_SetCellInfo()
with a NULL afsconf_dir pointer when attempting to create the default
CellServDB and ThisCell files (e.g., "localcell"), which causes the
bosserver to crash on startup when the cell configuration is not present.

Fix this by calling the static function to lookup the CellServDB
pathname when a afsconf_dir data object is not given.

Change-Id: I8d36f7c8afe6b4e13bfd04c421bf1109d1eb4238
Reviewed-on: https://gerrit.openafs.org/14061
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoauth: pass the directory name to _afsconf_CellServDBPath 76/14076/6
Michael Meffie [Thu, 20 Feb 2020 21:09:49 +0000]
auth: pass the directory name to _afsconf_CellServDBPath

Change the signature of the _afsconf_CellServDBPath() static function to
take just the base directory name of the CellServDB file instead of the
entire afsconf_dir data object. This makes it clear we do not need other
members of the afsconf_dir structure to compose the CellServDB path.

Change-Id: I57509b2ca09123e78df5533d63494c66b5b24cdf
Reviewed-on: https://gerrit.openafs.org/14076
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

4 years agoauth: retire writeconfig.c 75/14075/5
Michael Meffie [Thu, 20 Feb 2020 20:58:27 +0000]
auth: retire writeconfig.c

Move the afsconf_SetCellInfo() and afsconf_SetExtendedCellInfo() to the
cellconfig.c file with the other afsconf_dir functions.

Retire the now empty writeconfig.c file.  At one point in the distant
past afsconf_SetCellInfo() did not have a afsconf_dir argument, so it
probably made sense to have a separate file to write the configuration.
Later, the afsconf_dir argument was added to afsconf_SetCellInfo() and
afsconf_SetExtendedInfo() to reset the auth cache, so these functions
are now better placed in cellconfig.c.

Note the contents of writeconfig.c were moved verbatim (including
comments), so this commit should have no functional changes.

Change-Id: Idff76f0d2dfa2383a8617373f0e38235a94f20f1
Reviewed-on: https://gerrit.openafs.org/14075
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoopr: Define opr_mutex_t in lockstub.h 86/13886/7
Andrew Deason [Wed, 2 Oct 2019 20:14:21 +0000]
opr: Define opr_mutex_t in lockstub.h

Like we do for opr_cv_t, define an opr_mutex_t to be a plain int, to
allow opr mutexes to be defined easily without ifdef guards.

Change-Id: Ib90017ac098ebc68ffd89890d448aabb2321f63e
Reviewed-on: https://gerrit.openafs.org/13886
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoRedHat: support the ppc64le architecture 46/14046/2
Benjamin Kaduk [Sat, 25 Jan 2020 05:42:33 +0000]
RedHat: support the ppc64le architecture

Reported by zhenjiang.cai@powercore.com.cn.

FIXES 135065

Change-Id: I79718a8b4da8a73edf40e0221308c9babc5e85b5
Reviewed-on: https://gerrit.openafs.org/14046
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLinux: use override_creds when available 51/13751/4
Jeffrey Hutzelman [Thu, 2 May 2019 20:02:47 +0000]
Linux: use override_creds when available

Linux may perform some access control checks at the time of an I/O
operation, rather than relying solely on checks done when the file is
opened. In some cases (e.g. AppArmor), these checks are done based on
the current tasks's creds at the time of the I/O operation, not those
used when the file was open.

Because of this, we must use override_creds() / revert_creds() to make
sure we are using privileged credentials when performing I/O operations
on cache files. Otherwise, cache I/O operations done in the context of
a task with a restrictive AppArmor profile will fail.

Change-Id: Icbe60874c348d6cd92b0a186d426918b0db9b0f9
Reviewed-on: https://gerrit.openafs.org/13751
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agowarn when starting without keys 11/13911/8
Michael Meffie [Fri, 18 Oct 2019 17:43:36 +0000]
warn when starting without keys

The server processes will happily start without keys and then fail all
authenticated access, including database synchronization and local
commands with -localauth.  At least issue warnings to let admins know
the keys are missing and that akeyconvert or asetkey needs to be run.

The situation is not helped by fact the filenames of the key files have
changed between versions. In 1.6.x the (non-DES) keys were in the
rxkad.keytab file and in later versions they are in the KeyFile* files,
so if you are used to 1.6.x it is not obvious what is wrong.

Change-Id: Iff7fe9a5a5a0f5ea1f4e227d3f6129658f8eb598
Reviewed-on: https://gerrit.openafs.org/13911
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoimprove command-line help for --enable_peer_stats 72/14072/2
Mark Vitale [Wed, 19 Feb 2020 19:48:07 +0000]
improve command-line help for --enable_peer_stats

The command-line help for several OpenAFS servers lists an inaccurate
description for the --enable_peer_stats option:

   "enable RX transport statistics"

Improve the help description to be more clear and consistent with the
description for --enable-process-stats.

Introduced by the following commits:
cd3492d volser: Convert command line parsing to cmd
a5effd9 viced: Use libcmd for command line options
461603e vlserver: Use libcmd for command line parsing
0b9986c ptserver: Use libcmd for command line parsing

Change-Id: Ibe23c61d4b838f3a3185390b18d25494fffde2ca
Reviewed-on: https://gerrit.openafs.org/14072
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoLINUX 5.6: use struct proc_ops for proc_create 63/14063/2
Cheyenne Wills [Tue, 11 Feb 2020 18:29:42 +0000]
LINUX 5.6: use struct proc_ops for proc_create

The Linux commit d56c0d45f0e27f814e87a1676b6bdccccbc252e9
(proc: decouple proc from VFS with "struct proc_ops") was merged into
Linux 5.6rc1.  The commit replaces the 'file_operations' parameter for
proc_create with a new structure 'proc_ops'.

Conditionally initialize and use proc_ops structures instead of
file_operations structures for calls to proc_create.

Notes:
 * proc_ops.proc_ioctl is equivalent to file_operations.unlocked_ioctl
 * The macros HAVE_UNLOCKED_IOCTL and HAVE_COMPAT_IOCTL are both
   hardcoded to 1 in linux's fs.h
 * proc_ops.compat_ioctl is conditional on Linux's CONFIG_COMPAT macro
   which is a separate test from the HAVE_COMPAT_IOCTL macro

Change-Id: I8570ca499696b4c31b381543107453fbfe355376
Reviewed-on: https://gerrit.openafs.org/14063
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agomacos: add anchors to synthetic.conf grep pattern 62/14062/3
Marcio Barbosa [Fri, 7 Feb 2020 17:58:56 +0000]
macos: add anchors to synthetic.conf grep pattern

The grep pattern that checks if /etc/synthetic.conf already has an entry
for afs is intended to check if this file holds a single column entry
named afs. Unfortunately, the current version does not completely
enforce this restriction. To fix this problem, add anchors to the grep
pattern in question.

Change-Id: I15a1fa1c250027b7d3ab67e686cbfbae853251a2
Reviewed-on: https://gerrit.openafs.org/14062
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: silence bogus warning about dcListCount uninitialized 48/14048/3
Mark Vitale [Mon, 27 Jan 2020 01:17:40 +0000]
afs: silence bogus warning about dcListCount uninitialized

Commit 3be5880d1d2a0aef6600047ed43d602949cd5f4d 'afs: Avoid panics in
afs_InvalidateAllSegments' is correct, but at least one compiler (gcc
4.3.4 on SLES 11.3) is fooled into issuing a warning:

    [...]/afs_segments.c: In function 'afs_InvalidateAllSegments_once':
    [...]/afs_segments.c:506: error: 'dcListCount' may be used uninitialized in this function

To silence the bogus warning, initialize dcListCount when defined.

Change-Id: I5938c85c71d08ed61ec1f69a50afb19c9b31fa82
Reviewed-on: https://gerrit.openafs.org/14048
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agovos: fix name availability check in vos rename 20/13720/5
Michael Meffie [Mon, 22 Jul 2019 19:20:24 +0000]
vos: fix name availability check in vos rename

The UV_RenameVolume() function first updates the volume name in the
VLDB, then read-write volume header and backup volume header, and
finally all of the read-only volume headers. If this function is
interrupted or a remote site is not reachable, the names in some of the
volume headers will be out of sync with name in the VLDB entry.

The implementation of UV_RenameVolume() is idempotent, so can be safely
called with the same name as in the volume's VLDB entry. This could be
used to bring all the names in the volume headers in sync with the name
in the VLDB.

Unfortunately, due to the check of the -newname parameter, vos
rename will not invoke UV_RenameVolume() when the name in the VLDB has
already been changed.  The vos rename command attempts to verify the
desired name (-newname) is available before invoking UV_RenameVolume()
by simply checking if a VLDB entry exists with that name, and
incorrectly assumes when a VLDB entry exists with that name it is an
entry for a different volume.

Change the -newname check to allow vos rename to proceed when name has
already been set in the VLDB entry of the volume being renamed. This
allows admins to run vos rename command to complete a previously
incomplete rename operation and bring the names in the volume headers in
sync with the name in the VLDB entry.

Note: Before this commit, administrators could workaround this vos
rename limitation by renaming the volume twice, first to an unused
volume name, then to the actual desired volume name.

Remove the useless checks of the code1 return code after exit in
the RenameVolume() function. These checks for code1 are never performed
since the function exits early when the first VLDB_GetEntryByName()
fails for any reason.

Update the vos rename man page to show vos rename can be used to fix
previously interrupted/failed rename. Also document the -oldname
parameter accepts a numeric volume id to specify the volume to be
renamed.

Change-Id: Ibb5dbe3148e9b8295347925a59cd7bdbccbe8fe0
Reviewed-on: https://gerrit.openafs.org/13720
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agouss: more gcc9 truncation warning appeasement 49/14049/2
Mark Vitale [Mon, 27 Jan 2020 17:26:41 +0000]
uss: more gcc9 truncation warning appeasement

uss_procs_PickADir needs a larger buffer to avoid a truncation warning.
While here, replace some magic numbers with existing symbols.

Change-Id: If981dddfa50bdbc8c4730cf8038429f071b1d5be
Reviewed-on: https://gerrit.openafs.org/14049
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agotests: skip vos tests when a vlserver is already running 21/14021/5
Michael Meffie [Fri, 10 Jan 2020 15:54:20 +0000]
tests: skip vos tests when a vlserver is already running

The vos tests start a temporary vlserver process, which is problematic
when the local system already has an installed vlserver. Attempt to
temporarily bind a socket to the vlserver port, and if unable to bind
with an EADDRINUSE error, assume the vlserver is already running and
skip these tests.

Change-Id: I1dd3bc4c7ebcd2c7bffc8aca422222a50058090e
Reviewed-on: https://gerrit.openafs.org/14021
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: Remove osi_VMDirty_p 23/14023/4
Andrew Deason [Thu, 9 Jan 2020 18:28:57 +0000]
afs: Remove osi_VMDirty_p

The function osi_VMDirty_p is mentioned in a few places in src/afs,
but it has always been ifdef'd or commented out, ever since OpenAFS
1.0. Remove the dead code.

Change-Id: Ia7cad718114d91adf9e403e29f9ac976c3f08bfd
Reviewed-on: https://gerrit.openafs.org/14023
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoaklog: Make dummy write AIX-specific 22/14022/2
Andrew Deason [Thu, 9 Jan 2020 18:38:45 +0000]
aklog: Make dummy write AIX-specific

This weird write() call exists to work around some old AIX-specific
bug. The ifdef looks like it is intended to restrict this to pre-5
AIX, but it also turns this on for all non-AIX platforms.

Make this area AIX-specific, to avoid this weird write on other
platforms that have nothing to do with the relevant workaround.

Change-Id: I092bcadb4ecc6277ae01e44e6a957e6bacc0cf2d
Reviewed-on: https://gerrit.openafs.org/14022
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agotests: do not resolve addresses in vos/vl test 20/14020/3
Michael Meffie [Fri, 10 Jan 2020 14:06:38 +0000]
tests: do not resolve addresses in vos/vl test

The vos-t test adds a set of 10.* test addresses to a test vlserver and
runs vos to read them back.  When the test is run in an environment
where hosts have been assigned in the 10.* internal network, vos will resolve
the addresses to hostnames and the test fails.  Pass the -noresolve
option to vos for this test when checking for the expected list of
addresses.

Example test output before this commit:

    ./vos-t
    ...
    #   seen: 10.0.0.0
    10.0.0.1
    myhost.example.com
    10.0.0.3
    ...
    not ok 5 - vos output matches

Change-Id: Ief43fe180a0dfff211f28d5f47be6224270907a3
Reviewed-on: https://gerrit.openafs.org/14020
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoFBSD: Declare vnops/vfsops static 73/13973/4
Andrew Deason [Sun, 1 Dec 2019 21:39:04 +0000]
FBSD: Declare vnops/vfsops static

Declare our vnode and vfs operations as static functions, since they
are not referenced outside of osi_vfsops.c/osi_vnodeops.c. Shuffle
around the definitions in osi_vnodeops.c so that we don't need forward
declarations for the functions.

Change-Id: Idbbe05a8b248ac29c2795c365be6a4e99da536dd
Reviewed-on: https://gerrit.openafs.org/13973
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoFBSD: Remove support for 8.x and 9.x 42/13842/5
Andrew Deason [Sun, 1 Dec 2019 21:27:01 +0000]
FBSD: Remove support for 8.x and 9.x

According to <https://www.freebsd.org/security/unsupported.html>,
FreeBSD 8.x EoL was on August 1, 2015, and FreeBSD 9.x EoL was on
December 31, 2016. Remove our support for these versions, since they
haven't been supported by FreeBSD itself for a while.

FreeBSD 10.x EoL was on October 31, 2018, which has passed, but was
less than a year ago. So keep 10.x in for now.

Adjust our preprocessor checks accordingly:

- In FBSD-specific dirs, assume AFS_FBSD100_ENV and lower is always
  true. Assume __FreeBSD_version is always at least 1000000.

- In non-FBSD dirs, convert AFS_FBSD100_ENV and lower to AFS_FBSD_ENV.

Change-Id: I965e65d3b95573bb374661217b24b686c7b68ed2
Reviewed-on: https://gerrit.openafs.org/13842
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agotests: Explicitly build target 'all' by default 93/13993/3
Andrew Deason [Thu, 2 Jan 2020 02:25:05 +0000]
tests: Explicitly build target 'all' by default

Commit 68f40643 (Build tests by default) added new targets in our
top-level Makefile, that caused us to effectively run
'cd tests && make' as part of the default build. Since no explicit
target is provided, 'make' tries to build the first target in the
given Makefile. On some platforms (such as *BSD), 'make' finds the
first defined target as a pattern rule (%.c) from our included
makefiles, and tries to build the target %.c, which it cannot do. This
causes the build to fail with:

    cd tests && make
    make[3]: don't know how to make %.c. Stop

To fix this, just explicitly build the 'all' target when we build our
tests by default.

Change-Id: I319271482685ec35087c470d95fdcaec6e1d8c47
Reviewed-on: https://gerrit.openafs.org/13993
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

4 years agotests: Stop vlserver on errors 92/13992/3
Andrew Deason [Tue, 31 Dec 2019 18:25:32 +0000]
tests: Stop vlserver on errors

Currently, if we encounter an error and 'goto out' after starting the
test vlserver, we'll exit without stopping the test vlserver. This can
confuse the test harness, causing 'runtests' to hang forever.

To avoid this, move the afstest_StopServer() call to also run when
we're bailing out, but only if the server has actally started of
course.

Change-Id: Ice5a56c20bc8d2eac85b3e760850c4d85e4601a8
Reviewed-on: https://gerrit.openafs.org/13992
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

4 years agotests: Introduce afstest_GetProgname 91/13991/2
Andrew Deason [Tue, 31 Dec 2019 18:04:48 +0000]
tests: Introduce afstest_GetProgname

Currently, in tests/volser/vos-t.c we call afs_com_err as
"authname-t", which is clearly a mistake during some code refactoring
(introduced in commit 2ce3fdc5, "tests: Abstract out code to produce a
Ubik client").

We could just change this to "vos-t", but instead of specifying
constant strings everywhere, change this to figure out what the
current command is called, and just use that. Put this code into a new
function, afstest_GetProgname, and convert existing tests to use that
instead of hard-coding the program name given to afs_com_err.

Change-Id: I3ed02c89f93798568783c7d717e8fb2e39dcce14
Reviewed-on: https://gerrit.openafs.org/13991
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agolibtool: Serialize building libfoo.la and libfoo.a 17/14017/2
Andrew Deason [Tue, 7 Jan 2020 19:02:21 +0000]
libtool: Serialize building libfoo.la and libfoo.a

We have a few libraries where we have separate targets to build
libfoo.la (to get libfoo.so) and libfoo.a. Currently, these targets
can be built in parallel, and both are built with libtool. This can
cause problems because of two behaviors with libtool:

- When running --mode=link for libfoo.a or libfoo.la, it effectively
  runs 'rm -rf .libs/libfoo.*' to clean up its work area.

- When running --mode=link for libfoo.a, libtool sets up some scratch
  space in .libs/libfoo.ax to unpack various static libs.

So when 'make libfoo.a' is running, libtool creates a .libs/libfoo.ax
dir, and unpacks various object files inside of it. If while that is
running, 'make libfoo.la' runs, it causes libtool to remove that
directory and all its contents. This causes 'make libfoo.a' to fail
with confusing messages like this (for libafsrpc.a):

    /bin/sh ../../libtool --quiet --mode=link --tag=CC  gcc -static   -O  -o libafsrpc.a [...]
    find: '.libs/libafsrpc.ax/libopr_pic.a': No such file or directory
    ar: .libs/libafsrpc.ax/libfsint_pic.a/afscbint.cs.o: No such file or directory
    make[3]: *** [Makefile:59: libafsrpc.a] Error

To avoid this, prevent building libfoo.la and libfoo.a at the same
time, by just making libfoo.la depend on libfoo.a. Do this for all of
the libraries we build in this way: libafshcrypto, libkopenafs,
libafsauthent, and libafsrpc.

Change-Id: I821768b3b4cd99cf5bf98605068773347ada0fb2
Reviewed-on: https://gerrit.openafs.org/14017
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoubik: Introduce ugen_secproc_func 86/13986/3
Andrew Deason [Fri, 1 Nov 2019 20:19:23 +0000]
ubik: Introduce ugen_secproc_func

We currently specify the signature of the 'secproc' function callback
in multiple places. Consolidate them into a single typedef.

Change-Id: Ic785f47fc726bff6c37f7fd826f1e2626d006776
Reviewed-on: https://gerrit.openafs.org/13986
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agodoc: Document new rxgk options 47/13947/6
Andrew Deason [Wed, 9 Oct 2019 18:54:40 +0000]
doc: Document new rxgk options

Commit e5b1e6f1 (Add rxgk client options to vl and pt utilities) added
a couple of new command-line options related to rxgk, but didn't add
them to the relevant man pages.

Add a brief description of these new options to the manpages for pts,
vos, ptserver, and vlserver.

Change-Id: I2d9bfdeb0a31d396740ca2a4d42e14c025b6f79e
Reviewed-on: https://gerrit.openafs.org/13947
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: Fix EIO error when reading a 4G or larger file 02/14002/3
Cheyenne Wills [Thu, 2 Jan 2020 18:18:16 +0000]
afs: Fix EIO error when reading a 4G or larger file

When reading a file with a file length of >= 4G, the cache manager is
failing the read with an EIO error.

In afs_GetDCache, the call to IsDCacheSizeOK is passed a parameter that
contains only the lower 32bits of the file length (which requires a 64
bit value). This results in the EIO error if the length is over 2^32 -1.

The AFSFetchStatus.Length member needs to be combined with the
AFSFetchStatus.Length_hi to obtain the full 64bit file length.

Fix the calls to IsDCacheSizeOK to use the full 64bit file length.

Commit "afs: Check dcache size when checking DVs
7c60a0fba11dd24494a5f383df8bea5fdbabbdd7" - gerrit 13436 - added the
IsDCacheSizeOK function and the associated calls.

As a note, the AFSFetchStatus.DataVersion is the lower 32 bits of the
full 64bit version number, AFSFetchStatus.dataVersionHigh contains
the high order 32bits.  The function IsDCacheSizeOK is passed just the
32bit component, the only use of the parameter is in an error message.

Change-Id: Idbe6233bd6ef792ed2b92d9337aba334e23f1452
Reviewed-on: https://gerrit.openafs.org/14002
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agomacos: add entry for afs into synthetic.conf 28/13928/8
Marcio Barbosa [Sun, 22 Dec 2019 03:56:41 +0000]
macos: add entry for afs into synthetic.conf

The root mount point is read-only as of macOS 10.15. As a result, /afs
cannot be created at this location. To workaround this restriction,
macOS 10.15 provides an alternative way to create mount points at the
root. To make it possible, an entry for the mount point in question must
be added to /etc/synthetic.conf. The synthetic entities described in
this file are not physically present on the disk. Instead, they are
synthesized by the kernel during system boot.

This commit adds an entry for afs into the file mentioned above. Knowing
that this change only takes effect after reboot, also provide directions
to the user during the installation process.

Change-Id: I7a05f4b9a48e443dbaa20a624a92b8b54c510000
Reviewed-on: https://gerrit.openafs.org/13928
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agomacos: add script to notarize OpenAFS 71/13671/9
Marcio Barbosa [Sun, 22 Dec 2019 03:11:57 +0000]
macos: add script to notarize OpenAFS

In order to integrate the notarization process into our existing build
scripts, this patch introduces a script to automatically notarize the
OpenAFS package.

Change-Id: Ia9743cd39485e68de540b79b165b9d92020ad187
Reviewed-on: https://gerrit.openafs.org/13671
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoDo not build shared-only libs for --disable-shared 27/13927/4
Andrew Deason [Wed, 23 Oct 2019 20:46:16 +0000]
Do not build shared-only libs for --disable-shared

Commit 0f1e54c4 (Pass -shared when linking some shared libraries)
changed some of our linking rules to pass -shared to libtool when
linking. When building with the --disable-shared configure option,
this causes those linker rules to fail, since shared libraries are
disabled. Before commit 0f1e54c4, we could build with --disable-shared
successfully.

To allow us to build again with --disable-shared, just don't build the
relevant shared-only libraries at all, when shared libraries are
disabled. To accomplish this, introduce a new substitution variable,
SHARED_ONLY, which allows certain lines in Makefiles to become
commented-out when shared libraries are disabled. Update all of the
shared-only libraries to be built conditionally based on this
variable.

Except for libuafs.la, which appears to be not referenced by anything.
Just remove the rules for that instead.

Change-Id: I82084a08d2f9c12ca438bd7b1626e1376159c975
Reviewed-on: https://gerrit.openafs.org/13927
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agopts: Use cmd_AddParmAtOffset for common parms 46/13946/5
Andrew Deason [Sat, 26 Oct 2019 00:04:44 +0000]
pts: Use cmd_AddParmAtOffset for common parms

Update pts to use cmd_AddParmAtOffset and symbolic constants for our
common parameters, instead of using bare literals like '16'.

Change-Id: Ib8fe77983a6bba46c3182585774e067512449f0e
Reviewed-on: https://gerrit.openafs.org/13946
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agotests: Check if vlserver died during startup 42/13942/2
Andrew Deason [Wed, 30 Oct 2019 01:17:39 +0000]
tests: Check if vlserver died during startup

Currently, the volser/vos test starts a local vlserver to communicate
with. If the vlserver dies during startup, the spawned 'vos'
subprocesses take forever to run, since we need to wait for our Rx
calls to timeout for every operation.

To make it less annoying to detect and investigate errors that might
cause the vlserver to fail during startup, check if the vlserver dies
right away. We already sleep for 5 seconds when starting the vlserver,
so just check if the pid still exists after those 5 seconds.

Change-Id: I6c33059542fa975e4cb389b718f9da190cd13289
Reviewed-on: https://gerrit.openafs.org/13942
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agorx: Make rx_identity_free idempotent 45/13945/3
Andrew Deason [Mon, 9 Sep 2019 19:27:40 +0000]
rx: Make rx_identity_free idempotent

rx_identity_free sets the given identity to NULL, but it
unconditionally derefs the given identity. Make it a no-op for NULL
identities, to make related cleanup code and destructors simpler.

Change-Id: I863c72be71fb4b3056a2cd8fc2bf19cfb2d5dfbb
Reviewed-on: https://gerrit.openafs.org/13945
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agorx: Make rx_opaque_free idempotent 44/13944/2
Andrew Deason [Wed, 21 Aug 2019 17:43:03 +0000]
rx: Make rx_opaque_free idempotent

Currently rx_opaque_free sets the given argument to NULL, a style that
helps prevent double-frees. However, it doesn't check if the given
buffer is already NULL, which makes potential callers that use a 'goto
done'-style cleanup block do something like:

 done:
    if (buf)
        rx_opaque_free(&buf);

To avoid the extra if(), make rx_opaque_free a no-op if it's given a
NULL buffer, similar to how free(NULL) is a no-op on most platforms.

Slightly refactor how we reference our argument as well, to limit the
number of layers of indirection the code needs to deal with.

Do the same for rx_opaque_zeroFree.

Note that there are currently no callers of
rx_opaque_free/rx_opaque_zeroFree, but future commits will add some.

Change-Id: Ic86a9c63903bebbddd311912cfbcb61198e3f0b0
Reviewed-on: https://gerrit.openafs.org/13944
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoptserver: Fix WhoIsThisWithName indentation 43/13943/2
Andrew Deason [Tue, 24 Sep 2019 03:43:30 +0000]
ptserver: Fix WhoIsThisWithName indentation

Many lines in this block in WhoIsThisWithName are oddly indented by 1
more space than usual. Fix them.

Change-Id: I5e3ec4974cebc694c7b02c1ea6e037d4ec335a12
Reviewed-on: https://gerrit.openafs.org/13943
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoBuild tests by default 41/13941/2
Andrew Deason [Tue, 29 Oct 2019 22:22:04 +0000]
Build tests by default

While it's not feasible to run all of our tests by default during the
build, we should be able to at least make sure the tests can build.
So, make the default build targets also build our tests, by making the
'finale' target build the tests.

Change-Id: Ieadd48ba2774526de8a13136e6cc8a50434ed2f5
Reviewed-on: https://gerrit.openafs.org/13941
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agotests: Fix manpage tests for objdir builds 40/13940/2
Andrew Deason [Tue, 12 Nov 2019 02:34:27 +0000]
tests: Fix manpage tests for objdir builds

The manpage tests have a couple of problems when running for objdir
builds:

- We try to specify './tests-lib/perl5' as a directory to find our
  helper library. However, the cwd when we're running the tests is in
  an objdir build, where the helper library is in the srcdir. Fix this
  by using the SOURCE env var specified by the tests wrapper.

- All of these tests specify the directory in which to find the man
  pages in a subdir of BUILD, but our manpages are located in the src
  dir (since they are built by regen.sh, not by configure/make). Fix
  this by specifying a SOURCE-based directory instead.

To avoid needing to make the same change for each of these tests, also
refactor the manpage tests so each test only needs to specify the
subdirectory and command name, and get rid of some of the common
boilerplate.

Change-Id: I96be199b1dec8db0545ae3cf19d2595c4afe4cdd
Reviewed-on: https://gerrit.openafs.org/13940
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agomacos: prepare for notarization 70/13670/8
Marcio Barbosa [Tue, 26 Nov 2019 19:41:36 +0000]
macos: prepare for notarization

With the public release of macOS 10.14.5, all new and updated kernel
extensions must be notarized by Apple. To be taken into consideration,
all executables must be signed and the Hardened Runtime capability must
be enabled.

This patch adds the missing prerequisites mentioned above.

Change-Id: I2d3ad66cb7ce062b91d0616955f3bc2b06ca5822
Reviewed-on: https://gerrit.openafs.org/13670
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agomacos: packaging support for MacOS X 10.15 69/13669/7
Marcio Barbosa [Fri, 28 Jun 2019 03:40:55 +0000]
macos: packaging support for MacOS X 10.15

This commit introduces the new set of changes / files required to
successfully create the dmg installer on OS X 10.15 "Catalina".

Change-Id: I628a3210fa42b2f34ff78030930f83e836775392
Reviewed-on: https://gerrit.openafs.org/13669
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agomacos: add support for MacOS 10.15 68/13668/7
Marcio Barbosa [Mon, 18 Nov 2019 14:34:08 +0000]
macos: add support for MacOS 10.15

This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 10.15 "Catalina".

Change-Id: I849d4c837bf9ae36fe5c33356bc1c66a2fc513ac
Reviewed-on: https://gerrit.openafs.org/13668
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agomacos: upgrade *.xib files 35/13935/7
Marcio Barbosa [Fri, 13 Dec 2019 03:03:04 +0000]
macos: upgrade *.xib files

According to Xcode 11, the *.xib files updated by this commit use an
older format that is potentially insecure when decoded. To fix this
problem, Xcode automatically upgraded these files to the modern format.
These changes are required to build OpenAFS on Catalina (Xcode 11).

Change-Id: Ica8c464eff93496d87fc854b193bfb0dad07a3c2
Reviewed-on: https://gerrit.openafs.org/13935
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agomacos: tell the compiler the system include path 36/13936/9
Marcio Barbosa [Fri, 8 Nov 2019 02:56:13 +0000]
macos: tell the compiler the system include path

In order to support multiple SDKs, macOS Catalina no longer has the
/usr/include directory. As a result, the compiler needs to know where
these headers can be found. To successfully build OpenAFS on OSX 10.15,
set KROOT so the compiler knows the correct location of these headers.

Change-Id: I5ef33b34b6a4e6111983a63a2d34326ca4af9d30
Reviewed-on: https://gerrit.openafs.org/13936
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agotests: Fix most tests for objdir builds 39/13939/2
Andrew Deason [Tue, 12 Nov 2019 02:34:07 +0000]
tests: Fix most tests for objdir builds

Fix a few miscellaneous issues with building and running our tests in
objdir builds:

- Our C tests use -I$(srcdir)/../.. in the CFLAGS, so we can #include
  <tests/tap/basic.h>. However, basic.h actually gets copied from
  src/external/c-tap-harness/tests/tap/ to tests/tap/ during the
  build, and so basic.h is available in the objdir, not srcdir. For
  objdir builds, this causes building the tests to fail with failing
  to find basic.h. Fix this to use TOP_OBJDIR as the include path
  instead.

- Our 'make check' in tests/ tries to run ./libwrap; but our cwd will
  be in the objdir for objdir builds, and libwrap is a script in our
  srcdir. Fix this to run libwrap from the srcdir path.

- In tests/opr/softsig-t, it tries to find the 'softsig-helper' binary
  in the same dir as 'softsig-t'. However, softsig-t is just a script
  in the srcdir, but softsig-helper is a binary built in the objdir.
  Fix this to use the BUILD env var provided by the tests wrapper, by
  default.

Change-Id: Iff642613bfc88d0d7e348660dc62f59e6fa8af75
Reviewed-on: https://gerrit.openafs.org/13939
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoFBSD: Remove pre-8 code 12/13812/5
Andrew Deason [Mon, 26 Aug 2019 04:21:23 +0000]
FBSD: Remove pre-8 code

Commit 123f0fb1 (config: remove support for old FreeBSD releases)
removed our support for FreeBSD releases before FreeBSD 8. However,
various areas of code still reference the symbols from those old
versions (e.g. AFS_FBSD53_ENV). Remove our ifdef logic for these old
symbols, according to the following rules:

- In FBSD-specific dirs, assume AFS_FBSD80_ENV is always true (as well
  as the symbols for earlier versions)

- In non-FBSD dirs, convert AFS_FBSD80_ENV to AFS_FBSD_ENV (and do the
  same for all earlier versions)

This allows us to remove code that was specific to older FreeBSD
versions, and simplify some ifdef conditionals.

Also remove the definitions for AFS_FBSD80_ENV and earlier versions in
our existing param.h files.

With this commit, the functions afs_start, afs_vop_lock,
afs_vop_unlock, and afs_vop_islocked are now always unreferenced, so
remove them.

Change-Id: Ia5a5ba5ee5b71a86cb4514305e20f1bb34487100
Reviewed-on: https://gerrit.openafs.org/13812
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: Add ppc64le changes in osconf.m4 file. 80/13980/3
Yadavendra Yadav [Fri, 6 Dec 2019 09:53:34 +0000]
afs: Add ppc64le changes in osconf.m4 file.

If swig package is installed on a ppc64le system, build fails for
"libuafs" while running "shlib-build". "shlib-build" gets executed for
builing ukernel.so and this is triggered if "LIBUAFS_BUILD_PERL" is not
empty. Having "swig" package on system sets "LIBUAFS_BUILD_PERL" to
'LIBUAFS_BUILD_PERL' value. The reason for build failure was inside
"shlib-build", 'linker' was not set (it was empty). 'linker' value is
set based on SHLIB_LINKER, which was not defined in  osconf.m4 if build
system is ppc64le.

To fix this add ppc64le_linux26 case in osconf.m4 file.

Change-Id: I79d2f78b2af34207c81f4f5ab05fdc387404acad
Reviewed-on: https://gerrit.openafs.org/13980
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoutil: Use a struct for afsUUID_to_string 31/13831/12
Cheyenne Wills [Mon, 2 Dec 2019 20:12:00 +0000]
util: Use a struct for afsUUID_to_string

Replace the use of a character array with a structure that contains
the size of the buffer that is needed.  This allows the C compiler to
perform a type check to ensure the correct sized buffer is used. In
addition, the size of the buffer is now specified in just one location.

Change the signature of the afsUUID_to_string function to return a
pointer to the start of a formatted UUID. This allows the use of
afsUUID_to_string in a way that is consistent with other object
formatting functions:

    struct uuid_fmtbuf uuidstr;
    printf("... %s ...",
             afsUUID_to_string(uuid, &uuidstr));

Update callers to use the new uuid_fmtbuf struct when calling
afsUUID_to_string.

Change-Id: I6d6f86ce6c058defc6256e8e88dee4449dd4f7e6
Reviewed-on: https://gerrit.openafs.org/13831
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoviced: add opt to allow admin writes on RO servers 07/13707/7
Marcio Barbosa [Thu, 14 Nov 2019 20:29:56 +0000]
viced: add opt to allow admin writes on RO servers

Add the new option -admin-write to allow write requests from superusers
on file servers running in readonly mode (-readonly). This lets sites
run fileservers in readonly mode for normal users, but allows members of
the system:administrators group to modify content.

Change-Id: Id8ed3513a748815c07cb98e426c1d21ac300b416
Reviewed-on: https://gerrit.openafs.org/13707
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: Skip checking chunkBytes sanity for RW files 69/13969/2
Andrew Deason [Fri, 29 Nov 2019 17:42:47 +0000]
afs: Skip checking chunkBytes sanity for RW files

Currently, the IsDCacheSizeOK check can trigger a false positive for a
dcache, if the data in the dcache was populated by a local write to a
file that was later extended with sparse data.

For example: say a client opens a new file, and writes 4 bytes to
offset 0, and then writes 4 bytes to offset 0x400000. After the first
write, the first chunk for the file will contain just 4 bytes, and
after the second write, the first chunk is unchanged (since we're
writing to a different area of the file), but the file is now 0x400004
bytes long. The sparse area of the file will be correctly filled with
zeroes for local reads and on the fileserver, but the 4-byte chunk
causes IsDCacheSizeOK to complain and mark the dcache as invalid.

Even though nothing is wrong, this causes the following scary messages
to potentially appear in the kernel log, and the relevant dcache to be
invalidated:

    afs: Detected corrupt dcache for file 1.536870913.2.2: chunk 0 (offset 0) has 4 bytes, but it should have 131072 bytes
    afs: (dcache 0xfffffdeadbeefb4d, file length 4194308, DV 1, dcache mtime 1575049956, index 996, dflags 0x2, mflags 0x0, states 0x4, vcache states 0x1)
    afs: Ignoring the dcache for now, but this may indicate corruption in the AFS cache, or a bug.

It's probably difficult or impossible to detect if this specific case
is happening, so to avoid this scenario, just avoid doing the size
check at all for RW data from the cache.

Change-Id: Ia40ec838c525d9abc13a03be39028e4ca04a9457
Reviewed-on: https://gerrit.openafs.org/13969
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

4 years agoviced: prevent writes on readonly fileservers 34/13934/3
Marcio Barbosa [Thu, 14 Nov 2019 04:15:47 +0000]
viced: prevent writes on readonly fileservers

Currently, a fileserver can be initialized as readonly. In this mode,
writes on this server should not be allowed. Unfortunately, updates on
files stored by readonly fileservers are not completely prevented. In
some situations, the check for RO server is omitted (e.g. if the user is
the owner of the file to be updated). In other situations, the same
check is redundant.

To fix these problems, consolidate this check in one place.

Change-Id: Id53e15216404dfe691a87c7b4964ff08924c262c
Reviewed-on: https://gerrit.openafs.org/13934
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agosys: retry lsetpag if errno is EINTR 95/12295/5
Marcio Barbosa [Mon, 6 Jun 2016 17:03:54 +0000]
sys: retry lsetpag if errno is EINTR

The variable errno might be set by some system calls to indicate the
reason why the system call in question did not work as expected. If the
setpag system call is interrupted by a signal, the value of errno will
be EINTR. This value means that setpag did not succeed because it was
interrupted.

If lsetpag did not succeed and errno is equal to EINTR, try again.

Change-Id: Ibf306d62fc8d2fa9ccb0692f9031c5aa659b2bfe
Reviewed-on: https://gerrit.openafs.org/12295
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: afs_pag_wait() makes process unkillable 60/12260/7
Marcio Barbosa [Thu, 7 Nov 2019 03:10:12 +0000]
afs: afs_pag_wait() makes process unkillable

To enforce a maximum average rate of one PAG allocation per second,
afs_pag_wait(), called by afs_setpag*(), sleeps until the difference
between the current time and pag_epoch gets greater than pagCounter.
Unfortunately, this function ignores the code returned by afs_osi_Wait().
As a result, it is not possible to kill the process that requested the
new pag while afs_pag_wait() is sleeping.

To fix this problem, do not ignore the code returned by afs_osi_Wait().

Change-Id: I6be11a569edcafa6ecdf716e5315fc75f5a128e8
Reviewed-on: https://gerrit.openafs.org/12260
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>