13533 Commits

Author SHA1 Message Date
Marcio Barbosa
9d217903f0 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.

Reviewed-on: https://gerrit.openafs.org/14066
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 32d35db64061e4102281c235cf693341f9de9271)

Change-Id: I00a99819ac7d1d981695da3eae1bd60de1cb53ae
Reviewed-on: https://gerrit.openafs.org/15233
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-26 07:31:11 -05:00
Marcio Barbosa
5a48ce589a 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.

Reviewed-on: https://gerrit.openafs.org/14065
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 957b06984b77cba74bd90217b723220c1844809b)

Change-Id: If82cf4d2983e7b6f8975ca4a9fa104ee5e36b917
Reviewed-on: https://gerrit.openafs.org/15232
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-26 07:27:36 -05:00
Cheyenne Wills
3084117f10 Linux: Fix functions without prototypes
The Linux kernel build has -Wstrict-prototypes enabled and flags
functions without a proper prototype.  With clang-16 these warnings are
reported as errors when the kernel is configured with CONFIG_WERROR or
when openafs is configured with --enable-checking.

    src/libafs/MODLOAD-6.1.0-rc3-SP/osi_alloc.c:339:32: error: a
       function declaration without a prototype is deprecated in all
       versions of C [-Werror,-Wstrict-prototypes]
   osi_linux_verify_alloced_memory()
                                  ^
                                   void

Update function prototypes to comply with -Wstrict-prototypes.

There are no functional changes with this commit.

Reviewed-on: https://gerrit.openafs.org/15194
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 63db2de22ef75292463ec1f0979e32afc05d0b95)

Change-Id: I2e9c09c3b88ca3597720b1d8885537600d307418
Reviewed-on: https://gerrit.openafs.org/15275
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-26 07:22:36 -05:00
Cheyenne Wills
c990b0d086 libadmin: Fix RPCStatsStateGet 'rpc' prototype
clang-16 is flagging a incompatible-function-pointer-types warning which
results in build errors when --enable-warning is turned on.

   client.c:498:13: error: incompatible function pointer types passing
      'int (struct rx_connection *, afs_int32 *)'
      (aka 'int (struct rx_connection *, int *)') to parameter of type
      'int (*)(struct rx_connection *, afs_RPCStatsState_p)'
      (aka 'int (*)(struct rx_connection *, afs_RPCStatsState_t *)')
      [-Wincompatible-function-pointer-types]

    (conn, RXSTATS_QueryPeerRPCStats, &state, &st)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~

Update the 'util_RPCStatsStateGet()' function's parameter to match the
function type for the RPC functions actually being called.

Reviewed-on: https://gerrit.openafs.org/15180
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 97f0a20e50f027fe00adb22c39b71f0ac79f1ff7)

Change-Id: Icbbbd137fa6a404090ef7af94621100bb552d502
Reviewed-on: https://gerrit.openafs.org/15274
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-26 07:20:42 -05:00
Cheyenne Wills
973c5c585f clang-16: Fix simple unused-but-set variables
Clang-16 is flagging variables as unused-but-set-variables resulting in
build errors when --enable-warning is used.

   db_verify.c:996:9: error: variable 'builtinUsers' set but not used
      [-Werror,-Wunused-but-set-variable]
       int builtinUsers = 0;
           ^
Remove the variables that are set but never actually used.

This commit fixes the simpler cases where variables are only set but
not used elsewhere.

Reviewed-on: https://gerrit.openafs.org/15178
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit afafde158ff875d2459bb81ac373cde3e45dac03)

Change-Id: I65cd27325b768ba192831401f4ac71e94071ecc7
Reviewed-on: https://gerrit.openafs.org/15273
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-26 07:18:36 -05:00
Cheyenne Wills
f336d0aa01 clang-16: Fix conditionally unused-but-set variables
clang-16 is flagging unused-but-set variables which result in build
errors when --enable-warning is turned on.

   remote.c:485:15: error: variable 'pass' set but not used
       [-Werror,-Wunused-but-set-variable]
     afs_int32 pass;
              ^
These variables are actually used in specific cases depending on
build configuration (e.g. AFS_PTHREAD_ENV, etc.).

Relocate these variables so they are fully defined or referenced within
preprocessor '#if' blocks.

Reviewed-on: https://gerrit.openafs.org/15177
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 97018ace991d300a6ff75a1dcd1a69b4044f2b89)

Change-Id: Iee3a196d9c23a8725171db4a3a884a077f0e95ac
Reviewed-on: https://gerrit.openafs.org/15277
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:12:47 -05:00
Cheyenne Wills
fb30715639 clang-16: Fix unused-but-set 'for' control vars
clang-16 is flagging unused-but-set variables which result in build
errors when --enable-warning is turned on.  Several of these variables
are used within 'for(..)' loops but are not actually referenced anywhere
else.

  fcrypt.c:181:16: error: variable 'i' set but not used
     [-Werror,-Wunused-but-set-variable]
    afs_uint32 i, j;
               ^
Refactor the for statements to eliminate the unused variables.

Note, this commit is a little more complex than simply removing unused
variables.

Reviewed-on: https://gerrit.openafs.org/15176
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 05eb420829f9bca155c1d5af9fe96844db974770)

Change-Id: I80506cb8ae1c4bef67225eb11e3f640e8de52d26
Reviewed-on: https://gerrit.openafs.org/15271
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:10:46 -05:00
Cheyenne Wills
b87081682d crypto: Define krb5_keytype as krb5_enctype
When building with clang-16 and configured with --enable-checking, the
external source heimdal/krb5/crypto.c used in src/crypto/rfc3961 fails
with the following error:

  src/external/heimdal/krb5/crypto.c:702:28
   error: implicit conversion from enumeration type 'krb5_enctype' (aka
   'enum ENCTYPE') to different enumeration type 'krb5_keytype' (aka
   'enum krb5_keytype') [-Werror,-Wenum-conversion]
       *keytype = e->keytype->type; /* XXX */
                ~ ~~~~~~~~~~~~^~~~

Replace the enum definition of krb5_keytype with a typedef to
krb5_enctype and create an anonymous enum mapping of KEYTYPE_ARCFOUR to
ETYPE_ARCFOUR_HMAC_MD5.

It should be noted that krb5_keytype and KEYTYPE_ARCFOUR are only used
by the external file src/external/heimdal/krb5/crypto.c

Changing the type for krb5_keytype was suggested by Andrew Deason
(adeason@sinenomine.net).

Reviewed-on: https://gerrit.openafs.org/15189
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>
(cherry picked from commit c9ac7cdfb6365e3fc1914de80019a10328de1f4f)

Change-Id: I15a793b35cfa920e8db1a99c5575b4f3f55be0dd
Reviewed-on: https://gerrit.openafs.org/15270
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:09:06 -05:00
Cheyenne Wills
334debcd4c dumptool: Remove unused 'sflag' variable
clang-16 is flagging unused-but-set variables which result in build
errors when --enable-warning is turned on.

   ./dumptool.c:1285:54: error: variable 'sflag' set but not used
      [-Werror,-Wunused-but-set-variable]
       int errflg = 0, lflag = 0, iflag = 0, Fflag = 0, sflag = 0, Rflag = 0;

Within dumptool the '-s' option of the 'ls' subcommand sets the 'sflag'
variable, but the variable itself is never used anywhere else.

Remove the variable 'sflag', and ignore the '-s' option.

The sflag variable was unused in the commit that introduced the code:
"test-suite-pull-tools-directly-in-20020114" (fcb32c07ed6d)

Reviewed-on: https://gerrit.openafs.org/15181
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 3e9d41c98ecf07519ff6d2a1413615547ace13b8)

Change-Id: I4cd4584c6374a525714d392f98fb39be5406bdbc
Reviewed-on: https://gerrit.openafs.org/15269
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:07:34 -05:00
Cheyenne Wills
241dcae439 libuafs: include com_err.h in ukernel_swig.i
clang-16 is flagging an implicit-function-definition which results in a
build error when --enable-warning is turned on.

    PERLUAFS/ukernel_swig_perl.c:1585:9: error: call to undeclared
        function 'afs_com_err'; ISO C99 and later do not support
        implicit function declarations [-Wimplicit-function-declaration]
      afs_com_err("AFS::ukernel", code, "parsing line: '%s'", line);
      ^

Add an include for afs/com_err.h to resolve the warning.

Reviewed-on: https://gerrit.openafs.org/15179
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 4be3e5d31fa3fbe6c80ad0973430074124b157bc)

Change-Id: I62785fe6248cb4b26f680c2db044f59511a1e02e
Reviewed-on: https://gerrit.openafs.org/15268
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:06:14 -05:00
Cheyenne Wills
0b908b7b9b rx: Remove event_handler rx_pthread_* counters
The event_handler() function contains several counters that are
set and incremented but are not actually used.  Clang-16 is flagging
these with a 'unused-but-set-variable' warning resulting in build errors
when --enable-warnings is used.

rx_pthread.c:136:19: error: variable 'rx_pthread_n_event_expired' set
       but not used [-Werror,-Wunused-but-set-variable]
      unsigned long rx_pthread_n_event_expired = 0;

Several 'if' statements are used to conditionally set these variables,
but serve no other purpose. These 'if' statements can also be
eliminated.

Remove the unused rx_pthread_* counter variables as well as the
associated 'if' statements.  In addition the only purpose of the
'error' variable was to conditionally increment one of the removed
variables, remove the 'error' variable.

These variables have been 'unused but set' since the original commit
from IBM.

Reviewed-on: https://gerrit.openafs.org/15175
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit f7cb492c7e755ec91226c96cc82ad9f567f01f11)

Change-Id: I4dfdd7e536f6af642789fc51f6f055652c63a46d
Reviewed-on: https://gerrit.openafs.org/15267
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:04:37 -05:00
Mark Vitale
5af53db475 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.

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>
(cherry picked from commit 09ec1073b4c5d2eb70dcf5d8063018bc82e5a35e)

Change-Id: I84b1d4b8b9041242d64b03a84ad4392ff9778950
Reviewed-on: https://gerrit.openafs.org/15266
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:02:35 -05:00
Ganesh Chaudhari
05a4adcdff macos: Update postinstall instructions for MacOS 13
System preferences is getting replaced by System settings in MacOS 13.
So, this commit will address the required changes in the dialog box
which gets popped after installing OpenAFS.

Signed-off-by: Ganesh Chaudhari <gangovind@in.ibm.com>
Reviewed-on: https://gerrit.openafs.org/15150
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit c620c91416f726357d556ce043b6cc285cf87a8b)

Change-Id: I6d8da31dc3735cab93c2b2226d436960c77b78ff
Reviewed-on: https://gerrit.openafs.org/15264
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:49:09 -05:00
Ganesh Chaudhari
9c6503e117 macOS: Add support for aarch64-*-darwin* sysname
As of libtool 2.4.7, the supplied config.guess file modifies
the sysname returned on macOS arm64 from arm-*-darwin* to
aarch64-*-darwin*. As a result, trying to build OpenAFS on
macOS arm64 fails with the following message:

  configure: error: An AFS sysname is required

To avoid this problem, added support for aarch64-*-darwin*.

Signed-off-by: Ganesh Chaudhari <gangovind@in.ibm.com>
Reviewed-on: https://gerrit.openafs.org/15149
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit d38b068627f5e84cead88af85f904fea0c8edb6d)

Change-Id: I7685c2b75f62fe28b8723e00fba22f5f7fe795f1
Reviewed-on: https://gerrit.openafs.org/15263
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:47:33 -05:00
Ganesh Chaudhari
41e46e12ac macos: Add support for MacOS 13.0 (Ventura)
This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 13.0 “Ventura”.

Thank you Kailas Zadbuke (IBM) and Harish Sharma (IBM) for your help.

Reviewed-on: https://gerrit.openafs.org/15139
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit e5a97ef2b46c8821db81363f4917ef214fc34a5e)

Change-Id: I5092fe02a3bc3b7a6cb4ecfd4c8660278da9b0e8
Reviewed-on: https://gerrit.openafs.org/15262
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:45:52 -05:00
Marcio Barbosa
f6b088d2a7 klog.krb5: remove "save and reuse password" logic
In order to avoid repeated requests for the user's password, klog.krb5
caches and reuses it whenever necessary. However, with the introduction
of commit 3a9a5783cd1fd73902655f0876e2069b42688c94, klog.krb5 always
requests a TGT regardless of the state of writeTicketFile, eliminating
the need for possible extra requests for the user's password.

Moreover, krb5_get_init_creds_password() does not accept a custom
prompter on macOS (returns EINVAL). Consequently, if the -password
argument is omitted, klog.krb5 fails with the following error:

klog: Invalid argument Unable to authenticate in realm <REALM>

Given that the user won't be prompted for a password multiple times,
remove the "save and reuse password" logic and use krb5_prompter_posix()
as the prompter function (instead of klog_prompter).

Relevant issue identified by gangovind@in.ibm.com.

Reviewed-on: https://gerrit.openafs.org/14643
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Tested-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit a10f99dbe025c74fb488b501daaf1f9574830cec)

Change-Id: I6587283d93a2dc801c8a41f0663a6de1b5d8a045
Reviewed-on: https://gerrit.openafs.org/15261
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:44:19 -05:00
Marcio Barbosa
69f1ffb898 DARWIN: On macOS 12, mount afs on user's directory
Currently, /afs is mounted/unmounted by a LaunchDaemon. In order to
unmount /afs on restart/shutdown, this daemon runs umount -force /afs.
Unfortunately, SIP (System Integrity Protection) is not allowing the
LaunchDaemon in question to run this command successfully on macOS 12
(exclusively on restart/shutdown):

  umount: Operation not permitted

In this situation, afs can't be turned off correctly, leaving many
unkillable afsd processes lingering around. As a result, the
restart/shutdown process gets stuck indefinitely.

Fortunately, this problem doesn't happen if /afs is mounted on an user's
directory. That said, avoid this issue by mounting /afs on the current
user's directory (/Users/$USER/OpenAFS/afs). Notice that afs is still
accessible (including for other users) through a synthetic link added in
the root directory (/afs -> /Users/$USER/OpenAFS/afs).

Reviewed-on: https://gerrit.openafs.org/14925
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 1c7eda8ea83bee3e674435109efccbc6082e4765)

Change-Id: Idb013d76f00a78cfebd790900eabbcd6968029b7
Reviewed-on: https://gerrit.openafs.org/15260
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:42:37 -05:00
Marcio Barbosa
fd64dcd3fb macos: Packaging support for MacOS X 12.0
This commit introduces the new set of changes / files required to
successfully create the dmg installer on OS X 12.0 "Monterey".

Reviewed-on: https://gerrit.openafs.org/14924
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 873d803a3dc7acffd74c9432872bed4f6575abf9)

Change-Id: I4cbbbeb5eb740b4f7979fa2137cb7faa9027d774
Reviewed-on: https://gerrit.openafs.org/15259
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:40:52 -05:00
Marcio Barbosa
046e787f1f macos: Add support for MacOS 12.0
This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 12.0 "Monterey".

Reviewed-on: https://gerrit.openafs.org/14923
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 7a862f940b2e2f2169e267fc6deb31db8f3534c0)

Change-Id: I4f1b42002c670e15b3fecfd8d0cfb2f461b8d136
Reviewed-on: https://gerrit.openafs.org/15258
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:39:07 -05:00
Mark Vitale
fc80c74689 DARWIN: disable kextutil check for versions requiring notarization
Our kextutil signing check will fail for releases that require
notarization (Mojave 10.14.5 and up, Catalina 10.15 all versions),
because we aren't notarized yet at the time of the check.

Instead, disable the check for those releases.

Reviewed-on: https://gerrit.openafs.org/14222
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit d2e755e33a266df17169a1fc05db1e540b5e76af)

Change-Id: Ie191503cb3f57c60a2a9c31e638dc7f79c496591
Reviewed-on: https://gerrit.openafs.org/15257
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:37:39 -05:00
Mark Vitale
6652a63279 DARWIN: ensure OpenAFS.pkg is signed
Installation fails because the OpenAFS.pkg was inadvertently omitted
from the codesign logic.

Ensure that the package is signed.

Reviewed-on: https://gerrit.openafs.org/14221
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 336f5d91c6f4e93f77560d456fb29fbd82b237e5)

Change-Id: I58c0ca157653b76562ee7071a567db681d33fc2e
Reviewed-on: https://gerrit.openafs.org/15256
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:35:23 -05:00
Mark Vitale
d20def23d0 DARWIN: ensure PrefPane materials are properly signed
Notarization fails because some prefPane materials were inadvertently
omitted by the codesign logic.

Ensure that these objects are properly signed.

Reviewed-on: https://gerrit.openafs.org/14220
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit d3f8d8122880de9f5b25868b39efd1cc7d385ff6)

Change-Id: Ice6c954e41e375fbe8ac670586d2616c565f0499
Reviewed-on: https://gerrit.openafs.org/15255
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:33:52 -05:00
Marcio Barbosa
35fde5873a DARWIN: Replace afs_osi_cred by allocated ucred
Building the current version of OpenAFS on macOS Monterey arm64 results
in the following error:

 error: globals with authenticated null values are currently unsupported
 afs_ucred_t afs_osi_cred;

To avoid this problem, replace the global in question by a pointer to a
dynamically allocated afs_osi_cred (afs_osi_credp). Ideally we would
create a new credential with kauth_cred_create(), but this function is
not well documented and using it results in crashes. Moreover, if the
kauth_cred_dup() function were still available (private since XNU
1456.1.26 - macOS 10.6), we could also duplicate the current user's
credential during startup (like commit f40f466c7f did for BSD).

Reviewed-on: https://gerrit.openafs.org/14922
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 982d2f9dbe6586d06ffa2a61c02ea726b83b5902)

Change-Id: I720132478d4d1b742f63576e6a98e96c7a935885
Reviewed-on: https://gerrit.openafs.org/15254
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:32:04 -05:00
Andrew Deason
29f7182c3f Remove references to SunOS 4
We already removed support for Solaris versions before Solaris 8, in
commit e4c2810f ("Remove support for Solaris pre-8"), but there are
still some references to SunOS (meaning SunOS 4) in the tree. This is
even older than Solaris (aka SunOS 5), so get rid of these.

This commit removes most references to SunOS 4 regarding platform
support, and a few comments. This also removes a few comments that
were just wrong or nonsensical (e.g. CMAPPED in afs.h is used by
other platforms; some comments in platform-specific osi_file.c files
referenced SunOS for some reason).

Reviewed-on: https://gerrit.openafs.org/13506
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 6e5638ac7297701a99ea396dee1df8f56a6a50da)

Change-Id: I17821e2cd0050bb0a468bfadda2c446beafeb537
Reviewed-on: https://gerrit.openafs.org/15253
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:30:22 -05:00
Andrew Deason
3ee628c2dc Remove alpha_dux/alpha_osf references
Several files were still referencing the alpha_dux* and alpha_osf*
sysnames. The code for these platforms has been removed, so get rid of
this cruft.

Reviewed-on: https://gerrit.openafs.org/13339
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 809ee49b80d7bc0e720aaebe78fb9ecfd453065d)

Change-Id: Iae1f642df6cfb4c2e757f0fc381cb98eb5bf448e
Reviewed-on: https://gerrit.openafs.org/15252
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:22:36 -05:00
Marcio Barbosa
8ec429d0a3 DARWIN: Drop afs_event lock before destroying it
On macOS arm64, a lock (lck_mtx_t) must be released (lck_mtx_unlock)
before it can be destroyed/freed (lck_mtx_free -> lck_mtx_destroy). If
this rules isn't respected, the operating system in question will panic
with the following message:

  panic("lck_mtx_assert(): mutex (%p) not owned", lock);

Unfortunately, the current shutdown process of the osi_sleep module
doesn't respect this rule. As a result, macOS arm64 panics when the
OpenAFS client is shut down/restarted. To fix this problem, release
afs_event->lck (EVTLOCK_UNLOCK) before destroying it (EVTLOCK_DESTROY).

Reviewed-on: https://gerrit.openafs.org/14933
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 93b88935999ad25bc22daf64f9ebff30957e0a27)

Change-Id: Ib81c3decc748c06b2f99cfa155095bffd1048f57
Reviewed-on: https://gerrit.openafs.org/15251
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:16:25 -05:00
Marcio Barbosa
b5dd4df6ec macos: Add support for Apple Silicon
This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on Apple M1 (macOS 11+).

Notice that kexts on Apple silicon must support the arm64e architecture,
since they run in kernel space and must support the same architecture
and restrictions as other kernel code. On the other hand, the utilities
that run on user space, like vos, fs, and others, have to be built for
arm64 (currently).

Reviewed-on: https://gerrit.openafs.org/14746
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit cdbcb6f947feff528adc324dd6487b21083e23aa)

Change-Id: I854e7553b65956032a3c15aa427189bf8e4e3a0d
Reviewed-on: https://gerrit.openafs.org/15250
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:14:51 -05:00
Marcio Barbosa
33bcff698f macos: Refactor param.x86_darwin_200.h
In preparation for a future commit, try to make param.x86_darwin_200.h
more readable. Also, rename this file to param.darwin_200.h so code from
other architectures can be included in this header.

Reviewed-on: https://gerrit.openafs.org/14934
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 39b74c2c3725cfa39fc5076cd7803ee7d55923e3)

Change-Id: I184591c24fac37b4c5a2b6fab7b42850b3004744
Reviewed-on: https://gerrit.openafs.org/15249
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:12:50 -05:00
Marcio Barbosa
b9c3dbc0a6 build: Select param.h in sysname.m4
Currently, the way the file that will be used as param.h is selected
doesn't allow us to choose headers from other architectures, making
cross-compiling difficult. In an effort to facilitate this process,
select the header that will be used as param.h in sysname.m4. By doing
this, we will have more flexibility to select which header should be
used (in future commits).

Reviewed-on: https://gerrit.openafs.org/14914
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit d456bd9b258445f60745867c34ef7c7a8c7be187)

Change-Id: Iaaa372887ac17f352a6a4bb9c14b896e88e3b28b
Reviewed-on: https://gerrit.openafs.org/15248
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:11:10 -05:00
Marcio Barbosa
84b177ccc8 macos: Build afscell for supported architectures
Given that i386 is no longer supported, trying to build the current
version of afscell on macOS 11 (Big Sur) results in the following error:

error: The i386 architecture is deprecated. You should update your ARCHS
build setting to remove the i386 architecture.

To fix this problem, build afscell for all architectures listed in
ARCHS_STANDARD.

For the macosx11.0 sdk:

$ xcodebuild -showBuildSettings -scheme afscell -sdk macosx | grep ARCHS

    ARCHS = arm64 x86_64
    ARCHS_STANDARD = arm64 x86_64
    ARCHS_STANDARD_32_64_BIT = arm64 x86_64 i386
    ARCHS_STANDARD_32_BIT = i386
    ARCHS_STANDARD_64_BIT = arm64 x86_64
    ARCHS_STANDARD_INCLUDING_64_BIT = arm64 x86_64
    VALID_ARCHS = arm64 arm64e i386 x86_64

While here, add arm64 to the list of valid architectures.

Reviewed-on: https://gerrit.openafs.org/14745
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit dc6ced5e6d63ad89b1ad6f6b236a28b823abb59d)

Change-Id: I483c41a5954caa8ed080134d82f2e08a7c1973a4
Reviewed-on: https://gerrit.openafs.org/15247
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:07:57 -05:00
Cheyenne Wills
a0898c2d90 UKERNEL: avoid double include of roken.h
Commit 'afs: Replace strcpy &co by safer alternatives' (419f0cd7aa75719)
added an include for roken.h into UKERNEL/afsincludes.h.  Neither
UKERNEL/afsincludes.h or roken.h has a guard against a double include,
which can result in a build failure on older kernels (discovered on a
2.6.18 build):

 In file included from ~/openafs/src/afs/UKERNEL/afsincludes.h:30,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.h:15,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.c:24:
 include/roken.h:89: error: redefinition of typedef 'rk_socket_t'
 include/roken.h:89: error: previous declaration of 'rk_socket_t' was here
 In file included from ~/openafs/src/afs/UKERNEL/afsincludes.h:30,
          from ../afs/afsincludes.h:16,
          from ../afs/afs_bypasscache.h:68,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.c:30:

Since roken.h is from an external source, we cannot update it to add
the necessary check.

Update UKERNEL/afsincludes.h to add a check to see if it has already
been included.

auth/ktc.c has a required include for roken.h, but it also can pull in
UKERNEL/afsincludes.h as well.  This can result in a double include for
roken.h.

Update auth/ktc.c to only include roken.h if not building UKERNEL.

Reviewed-on: https://gerrit.openafs.org/15130
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit cc0ffc56e85eec4133bcc5e745efa28f5d3c53a7)

Change-Id: I4508c2d4bb878dadce649f0da2af16c9efa69b91
Reviewed-on: https://gerrit.openafs.org/15265
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:04:54 -05:00
Marcio Barbosa
5993965112 DARWIN: Declare/include functions before using them
Every function should be explicitly declared before it can be called.
Since -Wimplicit-function-declaration is usually a warning and not an
error, calling undeclared functions does not prevent us from building
the code.

However, apple-clang 12 makes this an error by default, prohibiting the
build of the current version on macOS 11 (Big Sur).

To fix this problem, declare functions before calling them. Also,
include mach/thread_act.h into afs_call.c so the declaration of
thread_terminate() can be found on macOS. Last, given that the third
argument of PIOCTL() (if UKERNEL is defined) is a pointer, cast it to
'long'. Doing so, we can avoid another inhibited warning. Notice that
this PIOCTL definition is scoped to a single file (src/auth/ktc.c).

Reviewed-on: https://gerrit.openafs.org/14744
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>
(cherry picked from commit f9c96d0fd609e14fcb8ff7d9269024e026f742cb)

Change-Id: I70dadc44d40e1fc877f9e0490e28636907432faa
Reviewed-on: https://gerrit.openafs.org/15246
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:59:15 -05:00
Andrew Deason
34d869996d afs: Organize setpag() declarations better
The current declarations for setpag() are a mess (not to be confused
with many other setpag functions, like afs_setpag()), accumulated
across various commits over time. Shuffle the #ifdef logic around, so
this becomes a much more straightforward #ifdef ladder, with one
declaration per conditional. And move the LINUX declaration to be next
to all of the others (even the LINUX setpag() is declared in
osi_groups.c, not osi_misc.c, so it's in the wrong spot anyway).

The resulting #ifdef logic should be identical to the original code,
but is now easier to follow. For the BSDs, it may look like we have
changed the conditional for the case of "XBSD && !DFBSD && !FBSD &&
!NBSD", but that's a very roundabout way of saying OBSD (OpenBSD).

Reviewed-on: https://gerrit.openafs.org/14883
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 738a6487ad088068d19a18c6330e01a40f2fd278)

Change-Id: I9dc933fa96fc6e7839c010c5207e644179343898
Reviewed-on: https://gerrit.openafs.org/15245
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:57:50 -05:00
Marcio Barbosa
b56d5cdfa8 bucoord: Introduce ubik_Call_SingleServer_BUDB_*
In an effort to avoid the usage of undeclared functions, add wrappers
for ubik_Call_SingleServer() (_BUDB_GetVolumes(), _BUDB_DumpDB()) and
adjust its callers accordingly.

Also, make sure that ubik_Call_SingleServer() uses the same signature as
ubik_Call(). This change helps us to get rid of casting errors.

Reviewed-on: https://gerrit.openafs.org/14886
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>
(cherry picked from commit 981b3d723ec56dad553be570147d1b2aa632f4e1)

Change-Id: I5893a939bc5cd64eec9dbbf1ce8a0dc5032c81f0
Reviewed-on: https://gerrit.openafs.org/15244
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:55:48 -05:00
Marcio Barbosa
1e6fd4ceae afs: Ensure dirEntry->name has room for entry name
Currently, the afs_dynroot_addDirEnt() function assumes that the caller
has allocated the directory to be large enough to hold the necessary
entry. In order to make sure that memory isn't being accidentally
stomped, use strlcpy to truncate instead of stomping on other memory.
That way, if the caller makes a mistake we don't silently corrupt memory.

We specifically do not assert that there is no truncation or panic if
truncation occurs, since the effect of a truncated entry in the
dynamic AFS root volume is limited and does not justify bringing down
the entire client.

Reviewed-on: https://gerrit.openafs.org/14938
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit aa9180652876a3ba9157776b69a6995ac4201d1b)

Change-Id: I21a402bb6e20f2546c61bdabde021817dd3827d8
Reviewed-on: https://gerrit.openafs.org/15243
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:53:43 -05:00
Michael Meffie
79c8c86399 fs: Trim trailing lsmount and flushmount path slashes
Remove trailing slashes from paths given to `fs lsmount` and `fs
flushmount`.  This makes for a more pleasant user experience when shell
tab completion is used to specify the paths.

Thanks to Stephan Wiesand for pointing out this issue.

Reviewed-on: https://gerrit.openafs.org/14779
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit a7a672cae871aa9cf9cc003a37579cb4df51b3fe)

Change-Id: I24a2ae323f64f2d73be8fbc26860fa2864e34bfe
Reviewed-on: https://gerrit.openafs.org/15242
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:52:04 -05:00
Andrew Deason
91f1155171 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.

Reviewed-on: https://gerrit.openafs.org/13301
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 252b3bcc75ea141ff93a7b3147865f4b952fcaca)

Change-Id: I12d0616059dd8115b109b1ffa4cafe6ddc4b1662
Reviewed-on: https://gerrit.openafs.org/15241
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:49:52 -05:00
Marcio Barbosa
581450c74c afs: Replace strcpy &co by safer alternatives
In addition to being unsafe, these functions (strcpy, strncpy, strcat,
and sprintf) are deprecated on macOS. Replace these functions by safer
alternatives (strlcpy, strlcat, snprintf, and afs_strdup).

Notice that, in order to use afs_strdup(), this commit adds the afs_util
library to the AFSPAGOBJS list. Given that afs_strcasecmp() is also
implemented in afs_util.c, src/crypto/hcrypto/kernel/strcasecmp.c can be
removed from the tree.

No functional change should be incurred by this commit.

This commit is a continuation of a patch initially developed by
cwills@sinenomine.net.

Reviewed-on: https://gerrit.openafs.org/14743
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>
(cherry picked from commit 419f0cd7aa75719dcf4df97e603ad4f0d936ddd9)

[cwills@sinenomine.net]
Part of the (419f0cd7aa) changes to afs_callback.c were pulled in to a
1.8.x specific commit:
    "afs: Avoid unbounded string copy in SRXAFSCB_GetLock()" (79a04c344)
In order to resync the code, the include roken.h in afs_callback.c
introduced in that commit needed to be removed.

Change-Id: Ica0e9bdc82de2b1e89e6d4b513e775b2809fbc34
Reviewed-on: https://gerrit.openafs.org/15240
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:28:30 -05:00
Mark Vitale
c7048f9a5c afs: remove dead code
afs_CheckLocks has been dead code since openafs-ibm-1_0.

No functional change incurred.

Reviewed-on: https://gerrit.openafs.org/13210
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 0839a3326858f7d7a0042614710dcf7316bb6018)

Change-Id: I1c564255990803dac7abe1789f2941bf4fa30b58
Reviewed-on: https://gerrit.openafs.org/15239
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:26:21 -05:00
Marcio Barbosa
fc5be911a0 UKERNEL: Remove flock -> usr_flock redirection
In order to replace 'struck flock' with 'struct usr_flock' and 'flock()'
with 'usr_flock()', the current version of src/afs/UKERNEL/sysincludes.h
defines flock to usr_flock. This can cause problems when trying to use
libroken in UKERNEL code, because roken.h redefines flock.

To avoid conflicts with libroken (included in a future commit), add a
new UKERNEL specific AFS_FLOCK -> usr_flock redirection. Doing so, the
flock -> usr_flock redirection can be removed. While here, also remove
'usr_flock()' as it shouldn't be called and is not defined in any header
file.

Reviewed-on: https://gerrit.openafs.org/14913
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>
(cherry picked from commit 51c0387aaa5ec507c6e29063ef56d98e2931402d)

Change-Id: I3c2d9de056bae3f2fed68f1ec183540b63584a43
Reviewed-on: https://gerrit.openafs.org/15238
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:24:20 -05:00
Andrew Deason
276632ea73 UKERNEL: Remove socket -> usr_socket redirection
Currently, src/afs/UKERNEL/sysincludes.h #defines 'socket' to
'usr_socket', in order for 'struct socket' declarations to use struct
usr_socket. Redefining a simple word/function like 'socket' can easily
cause issues, and currently makes it difficult to introduce libroken
callers in UKERNEL code. There are already several instances of
'#undef socket' in the tree for UKERNEL, suggesting that this wasn't a
good idea to start with.

Fortunately, this redefinition of 'socket' in UKERNEL seems
unnecessary, since the only place 'struct usr_socket' is actually
deferenced is inside src/rx/UKERNEL/rx_knet.c. So we can treat 'struct
usr_socket' as a struct definition that's just internal to rx_knet.c,
and no other code even needs to know about the struct, or think that
it's equivalent to 'struct socket'.

Most code in rx_knet.c already explicitly casts between 'struct
socket' and 'struct usr_socket'. The only exception is rxi_Recvmsg
starting in commits near 27c42be1 (ukernel-rx-knet-deref-20060126),
but this is easily fixed by adding an additional explicit cast.

Reviewed-on: https://gerrit.openafs.org/14887
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 17b16cb3989d1f41e314795515daf6c9b41cf1de)

Change-Id: I35c7b7fc61c1c741be928fa7beb889d8848f0b81
Reviewed-on: https://gerrit.openafs.org/15237
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:03:55 -05:00
Marcio Barbosa
f2f0be5e04 afs: Save size of sysname_info->name
In preparation for a future commit, save the size of sysname_info->name
by adding a new field (name_size) into the sysname_info struct. Also,
remove the sysname_info->allocked field, since now we can find out if
memory has been allocated by checking if sysname_info->name_size is
different than zero.

No functional change should be incurred by this commit.

Reviewed-on: https://gerrit.openafs.org/14912
Reviewed-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>
(cherry picked from commit c40c0bd00b7e49e67377e13f5b902c13a0e4478c)

Change-Id: I5a7d0d733dfc48d4d4eb5d00ef959ad980722e17
Reviewed-on: https://gerrit.openafs.org/15236
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:01:42 -05:00
Marcio Barbosa
6ba75f842f fs: add option to evaluate symlink or mtpt
Currently, several fs subcommands for Windows offer an option (-literal)
to evaluate symlink / mount point rather than the object it refers to.
Provide the same option on Unix for fs_getfid.

Reviewed-on: https://gerrit.openafs.org/14542
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 83d947c150322c3c7c65130ecf08719e466cae04)

Change-Id: Ife60e046c149f3586dbdad0e9b3fd6059967ece1
Reviewed-on: https://gerrit.openafs.org/15235
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 07:55:14 -05:00
Marcio Barbosa
f1fd9c9cae afs: refactor PNewStatMount and PFlushMount
Both functions use the same logic to find a name in a given directory.
To avoid repetition, move this logic to a separate function called
afs_LookupName().

No functional change is incurred by this commit.

Reviewed-on: https://gerrit.openafs.org/14541
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 981bc005f8161ca9ee52ea281c7d73e0e4e2461a)

Change-Id: I11f03146da86c91f83ad682df7ad1943cb4ab68f
Reviewed-on: https://gerrit.openafs.org/15234
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 07:49:06 -05:00
Cheyenne Wills
b176259593 cf: Handle autoconf linux checks with -Werror
When the linux kernel has been configured with CONFIG_WERROR=y, several
autoconf configure checks used to detect linux features fail due to the
compiler performing additional coding checks (e.g. unused variables,
uninitialized variables, etc.).  Typically these additional coding
checks produce compiler warnings, but with CONFIG_WERROR=y these
warnings are reported as compiler errors, resulting in a misconfigured
build environment.

When testing for kernel features, turn off -Werror in the autoconf
functions AC_CHECK_LINUX_BUILD and AC_CHECK_LINUX_FUNC by explicitly
setting the compiler '-Wno-error' flag.

In addition, fix the commented description for AC_CHECK_LINUX_BUILD to
match the actual parameters

Reviewed-on: https://gerrit.openafs.org/15191
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit e2ad1ca5f7355062e808f1717e7410b7ae893371)

Change-Id: I2c8ba4c421ed751aa6ff2899ea173c1e84053322
Reviewed-on: https://gerrit.openafs.org/15231
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-18 05:22:37 -05:00
Cheyenne Wills
57df4dff49 cf: Detect how to pass CFLAGS to linux kbuild
The autoconf test LINUX_KBUILD_USES_EXTRA_CFLAGS fails on modern kernels
when detecting how to pass CFLAGS to the compiler when building a Linux
kernel module.  The result of this test is used by configure when
testing for Linux kernel features.

In addition the EXTRA_CFLAGS method of passing compiler parameters has
been deprecated since Linux 2.6.24 commit:
    "kbuild: introduce ccflags-y, asflags-y and ldflags-y" (f77bf01425b)

The currently preferred method is to use the make variable 'ccflags-y'
to set compiler flags.

Replace the autoconf function LINUX_KBUILD_USES_EXTRA_CFLAGS with a new
test, LINUX_KBUILD_FIND_CFLAGS_METHOD, that checks the various ways to
pass compiler flags when building the kernel module.

Set the build variable "LINUX_KBUILD_CFLAGS_VAR" with the determined
method for setting kbuild compiler flags.

Update the AC_TRY_KBUILD26 autoconf function and the
make_kbuild_makefile.pl script to use the determined method for setting
the compiler flags for the kbuild process.

Background:

The autoconf test, LINUX_KBUILD_USES_EXTRA_CFLAGS, is used to determine
when to use either CFLAGS for EXTRA_CFLAGS when performing other
autoconf tests for Linux kernel features. The test was added with the
openafs commit:
 "linux-2624-20071123" (af7cf697ef8)

LINUX_KBUILD_USES_EXTRA_CFLAGS relied on the Linux 2.6.24 commit:
 "kbuild: check for wrong use of CFLAGS" (0c53c8e6eb4)
which caused a build failure if CFLAGS where used instead of
EXTRA_CFLAGS.

Later with the Linux 4.20 commit:
 "kbuild: remove old check for CFLAGS use" (0d91bf584fe)
which removed the build failure when CFLAGS were set and this resulted
in LINUX_KBUILD_USES_EXTRA_CFLAGS failing to properly determining how to
set compiler flags in the kbuild process.

As mentioned above, the EXTRA_CFLAGS method itself has been deprecated
in Linux 2.6.24, but support for using it has still present in the
kbuild processes.

Reviewed-on: https://gerrit.openafs.org/15196
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>
(cherry picked from commit f81b01de1a51f02798ac764fb2f6948b592639da)

Change-Id: Ib1e07bf6b8734a427a2682ca694fbe2e083f1ecd
Reviewed-on: https://gerrit.openafs.org/15230
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-18 05:17:41 -05:00
Andrew Deason
2cf76b31ce LINUX: Run the 'sparse' checker if available
The Linux kernel module buildsystem supports running an external tool
(by default, the 'sparse' tool) during the build to run additional
static checks on the source code to flag various warnings.

Tell the kernel build to run such a tool, if 'sparse' is installed.
This causes various new warnings in the build, such as:

  CHECK   /.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c
/.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c:73:1: warning: symbol 'afs_FreeOneToken' was not declared. Should it be static?
/.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c:160:1: warning: symbol 'afs_IsTokenExpired' was not declared. Should it be static?
/.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c:187:1: warning: symbol 'afs_IsTokenUsable' was not declared. Should it be static?

None cause the build to fail currently, but are just printed for
potential further investigation.

To control detecting 'sparse', add the --with-sparse configure option
and SPARSE configure variable. Default to checking if sparse is
available, and enabling it if so.

Further information on using sparse in the Linux kernel is available
in Documentation/sparse.txt in the Linux tree.

Using 'sparse' during the build was suggested by yadayada@in.ibm.com.

Reviewed-on: https://gerrit.openafs.org/13665
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 1210a8d6d96db2d84595d35ef81ec5d176de05e8)

Change-Id: I5d52b1eed48564956a687fba0419185b01621b13
Reviewed-on: https://gerrit.openafs.org/15229
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-18 05:12:31 -05:00
Stephan Wiesand
6cb9320825 Make OpenAFS 1.8.9
Update version strings for the 1.8.9 release, and add the
finishing touch to NEWS.

Change-Id: I8185cc177c1150d29d802df522e3b161dac7d75e
Reviewed-on: https://gerrit.openafs.org/15215
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
openafs-stable-1_8_9
2022-12-15 15:10:23 -05:00
Benjamin Kaduk
0ad4c50f91 viced: cope with signed length/position in FetchData
For legacy reasons, the "Pos" (initial position) and "Len" (length)
inputs to the RXAFS_FetchData and RXAFS_FetchData64 RPCs are represented
as signed integers (the corresponding StoreData RPCs use unsigned values).

The use of signed values allows for the possibility of negative inputs,
and of signed integer overflow (undefined behavior in C), though the latter
is unlikely to arise naturally given that the implementation uses a
common backend with 64-bit values.

In particular, if a negative "Pos" value is supplied, we end up in
FetchData_RXStyle() that performs either FDH_PREAD() or FDH_PREADV()
with the negative value as the position from which to read, which is
an error.  The error handling for those calls treats any error as
indicative of a problem with the volume or its underlying storage,
and takes the volume offline for salvage.  Furthermore, after the
maximum number of automatic salvages the volume is left offline for
administrator action.  This presents a simple route for
(unauthenticated) denial of service, as root.cell.readonly must be
available to all users of the cell, and can be brought offline in this
way; rendering root.cell.readonly unavailable would bring essentially
all access to the cell to a halt.  (Other volumes could be targeted as
well, subject to their corresponding ACLs.)

Since there is no valid use for a negative position or length input,
reject them outright from the common_FetchData64() implementation.
Also check for whether the combination requests a read that would
overflow a signed integer and reject that as well.

Thanks to Jeffrey Altman and Chaskiel Grundman for collaborating on
this change.

FIXES 135263

Reviewed-on: https://gerrit.openafs.org/15223
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 1fbbcbee0183aa7855c0e5d9d38aa89af75902db)

Change-Id: I1d634918789dddd5500ab50a0b508c142d83dc84
Reviewed-on: https://gerrit.openafs.org/15224
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2022-12-15 14:28:59 -05:00
Stephan Wiesand
f812d1125f Make OpenAFS 1.8.9pre2
Update version strings for the second 1.8.9 prerelease.

Change-Id: Ic45d60180097f85263b2bd81b0beb039c36ad51f
Reviewed-on: https://gerrit.openafs.org/15192
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
openafs-stable-1_8_9pre2
2022-11-10 12:11:53 -05:00