summaryrefslogtreecommitdiff
path: root/t/data/generate/rra-c-util/output/readme-md
blob: de3f21e81bd55238cc1ac05e89e7eb78e6ace4d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# rra-c-util

Copyright 2000, 2009-2010, 2013-2016 Russ Allbery <eagle@eyrie.org>.
Copyright 2009-2014 The Board of Trustees of the Leland Stanford Junior
University.  This software is distributed under a BSD-style license.
Please see the section [License](#license) below for more information.

## Blurb

rra-c-util is my collection of portability functions, utility functions,
Autoconf macros, and related shared C infrastructure, akin to gnulib but
without any GPL-covered code and additional support for Kerberos and PAM
development.  It serves as a common repository of code and infrastructure
used across multiple projects so that files have a canonical latest
version.  It's not intended for installation as a regular package;
instead, other packages are expected to copy files from here as needed.

## Description

The origins of this package are in the libinn utility library in INN.
Some of the utility and portability functions here are directly inspired
by or based on versions in older versions of INN, and I wrote and rewrote
considerable additional portability code and utility libraries when I took
over INN maintenance.  When I started maintaining other C packages, I
started copying pieces of libinn into those packages and merging it with
other portability and utility code.  Over time, each package gained a
slightly different version of various utility functions, replacements for
missing functions, and Autoconf macros.

The goal of this package is to merge all the various versions of any
portability or utility code that's used in more than one of my packages in
one place.  Then, each package can update to the latest rra-c-util version
before each release and gain from the improvements made for all other
packages.  You can think of it as my version of
[Gnulib](https://www.gnu.org/software/gnulib/), with everything released
under a permissive license (no GPL).

As well as C portability frameworks, Autoconf macros, and a general C
utility library, this package has also accumulated a considerable
collection of standard tests (for C and Perl packages) and a large library
of test utilities and support functions.  It also includes extensive
support for writing and testing PAM modules, and a portable implementation
of AFS PAGs.

This package uses the infrastructure of C TAP Harness for testing, but is
not the canonical version of `tests/runtests.c`, `tests/tap/basic.[ch]`,
`tests/tap/macros.h`, or `tests/tap/libtap.sh`.  Those files should be
pulled from [C TAP
Harness](https://www.eyrie.org/~eagle/software/c-tap-harness/) instead.

## Requirements

Everything requires a C compiler to build and expects an ISO C89 or later
C compiler and libraries.  Presence of strdup is also assumed, which is
guaranteed by POSIX 2008 but common in many earlier C libraries as well.
Otherwise, the files are meant to be copied into packages and the
requirements depend on which files one copies.

A Kerberos library, either MIT Kerberos or Heimdal, is required to build
this package as-is, since the Kerberos portability layer is built and
tested by default.  The other code will run fine without this requirement
when copied into other packages.

PAM libraries and headers are required to build the package as-is, since
the PAM supporting library is built and tested by default.  Other code can
be copied from this package without introducing a PAM dependency.

To build the the kafs portability layer, one of Linux, Mac OS X, Solaris
11, the kafs library that comes with either Heimdal or KTH Kerberos, the
kopenafs library that comes with newer OpenAFS, AFS header files (on any
other platform besides AIX or IRIX), or AFS libraries (on AIX and IRIX) is
required.  AIX binaries with AFS PAG support may not run on AIX systems
that do not have an AFS client installed due to how AIX handles system
calls.

To run the full test suite, and to use the Perl test support libraries,
Perl 5.6.2 or later is required.  The following additional Perl modules
will be used if present:

* IPC::System::Simple
* Test::MinimumVersion
* Test::Perl::Critic
* Test::Pod
* Test::Spelling
* Test::Strict

All are available on CPAN.  Those tests will be skipped if the modules are
not available.

To bootstrap from a Git checkout, or if you change the Automake files and
need to regenerate Makefile.in, you will need Automake 1.11 or later.  For
bootstrap or if you change configure.ac or any of the m4 files it includes
and need to regenerate configure or config.h.in, you will need Autoconf
2.64 or later.  Perl is also required to generate manual pages from a
fresh Git checkout.

## Building

You can build rra-c-util with:

```
    ./configure
    make
```

Pass `--enable-kafs` to configure to attempt to build kafs support, which
will use either an existing libkafs or libkopenafs library or build the
kafs replacement included in this package.  You can also add
`--without-libkafs` to force the use of the internal kafs replacement.

Pass `--enable-silent-rules` to configure for a quieter build (similar to
the Linux kernel).  Use `make warnings` instead of make to build with full
GCC compiler warnings (requires a relatively current version of GCC).

Normally, configure will use `krb5-config` to determine the flags to use
to compile with your Kerberos libraries.  If `krb5-config` isn't found, it
will look for the standard Kerberos libraries in locations already
searched by your compiler.  If the the `krb5-config` script first in your
path is not the one corresponding to the Kerberos libraries you want to
use or if your Kerberos libraries and includes aren't in a location
searched by default by your compiler, you need to specify a different
Kerberos installation root via `--with-krb5=PATH`.  For example:

```
    ./configure --with-krb5=/usr/pubsw
```

You can also individually set the paths to the include directory and the
library directory with `--with-krb5-include` and `--with-krb5-lib`.  You
may need to do this if Autoconf can't figure out whether to use `lib`,
`lib32`, or `lib64` on your platform.

To specify a particular `krb5-config` script to use, either set the
`PATH_KRB5_CONFIG` environment variable or pass it to configure like:

```
    ./configure PATH_KRB5_CONFIG=/path/to/krb5-config
```

To not use `krb5-config` and force library probing even if there is a
`krb5-config` script on your path, set `PATH_KRB5_CONFIG` to a nonexistent
path:

```
    ./configure PATH_KRB5_CONFIG=/nonexistent
```

`krb5-config` is not used and library probing is always done if either
`--with-krb5-include` or `--with-krb5-lib` are given.

GSS-API libraries are found the same way: with `krb5-config` by default if
it is found, and a `--with-gssapi=PATH` flag to specify the installation
root.  `PATH_KRB5_CONFIG` is similarly used to find krb5-config for the
GSS-API libraries, and `--with-gssapi-include` and `--with-gssapi-lib` can
be used to specify the exact paths, overriding any `krb5-config` results.

## Testing

rra-c-util comes with an extensive test suite, which you can run after
building with:

```
    make check
```

If a test fails, you can run a single test with verbose output via:

```
    tests/runtests -o <name-of-test>
```

Do this instead of running the test program directly since it will ensure
that necessary environment variables are set up.

To enable tests that don't detect functionality problems but are used to
sanity-check the release, set the environment variable `RELEASE_TESTING`
to a true value.  To enable tests that may be sensitive to the local
environment or that produce a lot of false positives without uncovering
many problems, set the environment variable `AUTHOR_TESTING` to a true
value.

## Using This Code

While there is an install target, it's present only because Automake
provides it automatically.  Its use is not recommended.  Instead, the code
in this package is intended to be copied into your package and refreshed
from the latest release of rra-c-util for each release.

You can obviously copy the code and integrate it however works best for
your package and your build system.  Here's how I do it for my packages as
an example:

* Create a portable directory and copy `macros.h`, `system.h`,
  `stdbool.h`, and `dummy.c` along with whatever additional functions that
  your package uses that may not be present on all systems.  If you use
  much of the `util` directory (see below), you'll need `asprintf.c`,
  `reallocarray.c`, and `snprintf.c` at least.  If you use
  `util/network.c`, you'll also need `getaddrinfo.c`, `getaddrinfo.h`,
  `getnameinfo.c`, `getnameinfo.h`, `inet_*.c`, and `socket.h`.  You'll
  need `winsock.c` for networking portability to Windows.

* Copy the necessary portions of `configure.ac` from this package into
  your package.  `configure.ac` is commented to try to give you a guide
  for what you need to copy over.  You will also need to make an `m4`
  subdirectory, add the code to `configure.ac` to load Autoconf macros
  from `m4`, and copy over `m4/snprintf.m4` and possibly `m4/socket.m4`
  and `m4/inet-ntoa.m4`.

* Copy the code from `Makefile.am` for building `libportable.a` into your
  package and be sure to link your package binaries with `libportable.a`.
  If you include this code in a shared library, you'll need to build
  `libportable.la` instead; see the Automake manual for the differences.
  You'll need to change `LIBRARIES` to `LTLIBRARIES` and `LIBOBJS` to
  `LTLIBOBJS` in addition to renaming the targets.

* Create a `util` directory and copy over the portions of the utility
  library that you want.  You will probably need `messages.[ch]` and
  `xmalloc.[ch]` if you copy anything over at all, since most of the rest
  of the library uses those.  You will also need `m4/vamacros.m4` if you
  use `messages.[ch]`.

* Copy the code from `Makefile.am` for building `libutil.a` into your
  package and be sure to link your package binaries with `libutil.a`.  As
  with `libportable.a`, if you want to use the utility functions in a
  shared library, you'll need to instead build `libutil.la` and change
  some of the Automake variables.

* If your package uses a TAP-based test suite written in C, consider using
  the additional TAP utility functions in `tests/tap` (specifically
  `messages.*`, `process.*`, and `string.*`).

* If you're using the Kerberos portability code, copy over
  `portable/krb5.h`, `portable/krb5-extra.c`, `m4/krb5.m4`,
  `m4/lib-depends.m4`, `m4/lib-pathname.m4`, and optionally
  `util/messages-krb5.[ch]`.  You'll also need the relevant fragments of
  `configure.ac`.  You may want to remove some things from `krb5.h` and
  `krb5-extra.c` the corresponding configure checks if your code doesn't
  need all of those functions.  If you need `krb5_get_renewed_creds`, also
  copy over `krb5-renew.c`.  Don't forget to add `$(KRB5_CPPFLAGS)` to
  `CPPFLAGS` for `libportable` and possibly `libutil`, and if you're
  building a shared library, also add `$(KRB5_LDFLAGS)` to `LDFLAGS` and
  `$(KRB5_LIBS)` to `LIBADD` for those libraries.

  For a Kerberos-enabled test suite, also consider copying the
  `kerberos.*` libraries in `tests/tap` for a Kerberos-enabled test suite.
  If you want to use `kerberos_generate_conf` from `tests/tap/kerberos.c`,
  also copy over `tests/data/generate-krb5-conf`.

* For testing that requires making Kerberos administrative changes,
  consider copying over the `kadmin.*` libraries in `tests/tap`.

* For testing packages that use remctl, see the `tests/tap/remctl.c` and
  `tests/tap/remctl.h` files for C tests and `tests/tap/remctl.sh` for
  shell scripts.

* If you're using the kafs portability code, copy over the `kafs`
  directory, `m4/kafs.m4`, `m4/lib-pathname.m4`, `portable/k_haspag.c`,
  the code to build kafs from `Makefile.am`, and the relevant fragments of
  `configure.ac`.

* If you're using the PAM portability code, copy over `pam-util/*`,
  `portable/pam*`, `m4/pam-const.m4`, and the relevant fragments of
  `configure.ac`.

* Copy over any other Autoconf macros that you want to use in your package
  from the m4 directory.

* Copy over any generic tests from `tests/docs` and `tests/perl` that are
  appropriate for your package.  If you use any of these, also copy over
  the `tests/tap/perl` directory and `tests/data/perl.conf` (and customize
  the latter for your package).

* If the package embeds a Perl module, copy over any tests from the
  `perl/t` directory that are applicable.  This can provide generic
  testing of the embedded Perl module using Perl's own test
  infrastructure.  If you use any of these, also copy over the
  `perl/t/data/perl.conf` file and customize it for your package.  You
  will need to arrange for `perl/t/data` to contain copies of the
  `perlcriticrc` and `perltidyrc` files, either by making copies of the
  files from `tests/data` or by using make to copy them.

I also copy over all the relevant tests from the `tests` directory and the
build machinery for them from `Makefile.am` so that the portability and
utility layer are tested along with the rest of the package.  The test
driver should come from C TAP Harness.

## Support

The [rra-c-util web
page](https://www.eyrie.org/~eagle/software/rra-c-util/) will always have
the current version of this package, the current documentation, and
pointers to any additional resources.

For bug tracking, use the [issue tracker on
GitHub](https://github.com/rra/rra-c-util/issues).  However, please be
aware that I tend to be extremely busy and work projects often take
priority.  I'll save your report and get to it as soon as I can, but it
may take me a couple of months.

## Source Repository

rra-c-util is maintained using Git.  You can access the current source on
[GitHub](https://github.com/rra/rra-c-util) or by cloning the repository
at:

https://git.eyrie.org/git/devel/rra-c-util.git

or [view the repository on the
web](https://git.eyrie.org/?p=devel/rra-c-util.git).

The eyrie.org repository is the canonical one, maintained by the author,
but using GitHub is probably more convenient for most purposes.  Pull
requests are gratefully reviewed and normally accepted.

## License

The rra-c-util package as a whole is covered by the following copyright
statement and license:

> Copyright 2000, 2009-2010, 2013-2016
>     Russ Allbery <eagle@eyrie.org>
>
> Copyright 2009-2014
>     The Board of Trustees of the Leland Stanford Junior University
>
> Permission is hereby granted, free of charge, to any person obtaining a
> copy of this software and associated documentation files (the "Software"),
> to deal in the Software without restriction, including without limitation
> the rights to use, copy, modify, merge, publish, distribute, sublicense,
> and/or sell copies of the Software, and to permit persons to whom the
> Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> DEALINGS IN THE SOFTWARE.

Some files in this distribution are individually released under different
licenses, all of which are compatible with the above general package
license but which may require preservation of additional notices.  All
required notices, and detailed information about the licensing of each
file, are recorded in the LICENSE file.

Files covered by a license with an assigned SPDX License Identifier
include SPDX-License-Identifier tags to enable automated processing of
license information.  See https://spdx.org/licenses/ for more information.

For any copyright range specified by files in this package as YYYY-ZZZZ,
the range specifies every single year in that closed interval.