Compare commits

..
61 Commits
Author SHA1 Message Date
Joachim Wiberg 67529f2283 debian: update symbols file
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 10:24:05 +01:00
Joachim Wiberg 8e69676943 Increment ABI version 5.2.0 -> 5.3.0
The GNU libtool numbers are just SO confusing.

 - New interfaces (new functions) added/removed/changed: 7 -> 8
 - Interfaces added: 2 -> 3

End result, steps 5.2.0 to 5.3.0, which makes sense.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 09:26:04 +01:00
Joachim Wiberg 76faae4292 Update changelogs, and bump version in prep. for v2.4.0 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 09:18:22 +01:00
Joachim Wiberg e928c30fbd Revert "Travis-CI: disable clang temporarily for Coverity Scan run"
This reverts commit 951050fdd2.
2021-03-27 09:05:31 +01:00
Joachim Wiberg 3512201a58 Travis-CI: install to /tmp/foo and run distcheck at the end
- We shouldn't run ls -lr /tmp, in particular when Coverity runs, it
  keeps a LOT of files in /tmp causing Travis to terminate our jobs
- make check is cool, but distcheck also verifies our Makefile.am
  rules, ensuring make check also works from an unpacked tarball

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 08:56:27 +01:00
Joachim Wiberg dc5c4ae36c systemf(): simplify further, exited OK or was signaled
Coverity highlighted a problem with logically dead code from the change
prior that triggered this refactor.  When system() returns we may have
exited either normally or due to a signal.

My reasoning behind systemf() is to allow users to treat external calls
as any other syscall, abstracting away the WIFFOO() macros.  This leaves
us with either the return value of the external program >= 0, or -1 and
errno for everything else.  I.e., if fork() or alloca() fails we may get
ENOMEM and if the program doesn't catch signals properly, EINTR.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 08:48:09 +01:00
Joachim Wiberg 748948b665 Minor, use .svg Travis status badge
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 08:48:01 +01:00
Joachim Wiberg 951050fdd2 Travis-CI: disable clang temporarily for Coverity Scan run
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 08:09:17 +01:00
Joachim Wiberg d5c5996f03 Minor, whitespace
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 08:06:17 +01:00
Joachim Wiberg f5808e557e Add strtrim(), trims leading and trailing white-space from a string
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 08:05:36 +01:00
Joachim Wiberg d4b554ccdc Add erasef(), formatted version of erase()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-27 07:08:49 +01:00
Joachim Wiberg 098a020843 Bump version, 2.4.0 development cycle
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-26 12:39:32 +01:00
Joachim Wiberg 2040569f0a Add touchf(), formatted version of touch()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-26 12:39:32 +01:00
Joachim Wiberg 733a7062e9 Minor, whitespace
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-26 12:37:05 +01:00
Joachim Wiberg 7ad11a31df touch(): behavioral change, call utimensat() first, then mknod()
Optimize for the case the file exists already.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-26 12:35:41 +01:00
Joachim Wiberg 8ce46eb439 systemf(): fix improper handling of WEXITSTATUS()
The call to system() may return -1, e.g. if fork() fails or return
status from execl() cannot be read.  In these cases we should end
immediately and not call WIFEXITED() et al.

Also, WEXITSTATUS() should only be called if WEXITED() returns true.

For details, see system(3) and wait(2).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-26 12:32:43 +01:00
Joachim Wiberg c15e883427 tests: update systemf() test to detect improper return code on error
Non-existing programs should return 127, and
killing ourselves with -9 should return -1

For details, see system(3).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-26 12:29:55 +01:00
Joachim Wiberg 63d82da62d Update changelogs and bump version for v2.3.1 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 15:13:40 +01:00
Joachim Wiberg dd1c67b2b6 debian: add missing files to copyright
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 15:10:05 +01:00
Joachim Wiberg 08d9a90945 Makefile: use debuild to build .deb packages, also runs lintian
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 09:29:42 +01:00
Joachim Wiberg beba419a0f debian: makepath.c is copyright me, licensed as isc
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 09:29:01 +01:00
Joachim Wiberg 3d695eede5 Update copyright years and author surname
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 09:28:41 +01:00
Joachim Wiberg 6e18edea93 debian: set dist to stable, that's the only channel currently
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 08:28:18 +01:00
Joachim Wiberg 9c89daf770 Update changelogs and bump version for v2.3.0 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 08:24:30 +01:00
Joachim Wiberg b3d4674bf7 Makefile: add .sha256 checksums to release target
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 08:23:07 +01:00
Joachim Wiberg aa4576d5ea configure: enable tar.gz dist archives, by popular demand
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 08:22:32 +01:00
Joachim Wiberg ae56c9e33c debian: sync rules with libuev
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 08:21:42 +01:00
Joachim Wiberg 3387c737be debian: update symbols file, new functions introduced in 2.3.0
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-12 08:21:23 +01:00
Joachim Wiberg 8d90ede158 Update changelog with new function
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-01 19:12:44 +01:00
Joachim Nilsson b1fe8a1271 debian: Update .gitignore
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-06-02 06:56:41 +02:00
Joachim Nilsson 044c2621ac Add support for truncatef(), formatted truncate() replacement
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-06-02 06:56:02 +02:00
Joachim Nilsson 7396dd83c7 Merge pull request #15 from yangfl/upstream
Fix #14: Avoid (some) hard-coded pathes in tests
2020-06-01 17:18:11 +02:00
yangfl e5fe988cdc Avoid (some) hard-coded pathes in tests 2020-06-01 23:04:29 +08:00
Joachim Nilsson 824da13977 Update ChangeLog, added fremove()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-29 00:33:39 +02:00
Joachim Nilsson efb1470008 Update ChangeLog with ETIMEDOUT fix to telnet_open()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 23:23:21 +02:00
Joachim Nilsson d2d0792c06 telnet_open(): Handle ETIMEDOUT in connect()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 23:20:55 +02:00
Joachim Nilsson 711c59e3a6 telnet: Refactor, rename local variable
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 23:20:55 +02:00
Joachim Nilsson f85ff3c835 tests: Add fremove() pass to fopenf() unit test for cleanup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 23:18:47 +02:00
Joachim Nilsson 16ea69adb4 Add support for fremove(), formatted remove() replacement
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 23:18:10 +02:00
Joachim Nilsson ae492581f8 tests: Keep same width for pass sub-headings as as test framework
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 23:17:50 +02:00
Joachim Nilsson d16385415c Simplify va_start/_end handling and return ENOMEM if alloca() fails
Be consistent with errno codes from libite, we already have other APIs
that return ENOMEM if alloca() fails, so let's do the same for these
new ones as well.

Also, simplify va_start()/va_end() handling in these APIs, no point
in the extra complexity before this patch.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 23:14:56 +02:00
Joachim Nilsson d27518c5b8 Bump version for 2.3.0-dev release cycle
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-04-27 22:45:41 +02:00
Joachim Nilsson 724926896a Add mising bullet and document new APIs better 2020-03-26 05:41:41 +01:00
Joachim Nilsson ef04307b4a debian: Update symbols file, new APIs introduced in v2.2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:41:44 +01:00
Joachim Nilsson 5d035d955e debian: Add missing libtool to Build-Depends
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:38:25 +01:00
Joachim Nilsson b65175782d Bump ABI version, new APIs added
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:38:25 +01:00
Joachim Nilsson c27a8e7ec6 Update changelogs and bump version for v2.2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 16:01:46 +01:00
Joachim Nilsson d231c1e1eb Revert "Travis-CI: Disable clang temporarily for Coverity Scan run"
This reverts commit 2a6adeebcd.
2020-03-16 10:41:27 +01:00
Joachim Nilsson 247fb67274 Add Coverity Scan badge
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:37:21 +01:00
Joachim Nilsson c716cc5835 copyfile(): Check return value of fstat(), prevent faulty futimens()
Found by Coverity Scan

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:50 +01:00
Joachim Nilsson e81ce85867 rsync(): Fix possible memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:50 +01:00
Joachim Nilsson 549f325c21 rsync(): Fix variable shadowing, found by clang-tidy
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:46 +01:00
Joachim Nilsson 2a6adeebcd Travis-CI: Disable clang temporarily for Coverity Scan run
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:56:23 +01:00
Joachim Nilsson cb2beacf2c Travis-CI: Add support for Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:55:27 +01:00
Joachim Nilsson 256b6ba038 Add origin section to README, better place for history or project
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:48:55 +01:00
Joachim Nilsson 61d9b5fac7 Update Changelog for upcoming v2.2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:43:48 +01:00
Joachim Nilsson 38ad841389 Bump version for v2.2.0 release cycle
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:39:17 +01:00
Joachim Nilsson f1a1a21569 Add support for systemf(), formatted system() replacement
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:32:52 +01:00
Joachim Nilsson 7f3f4df9e9 Add support for fmkpath(), formatted string mkpath()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-11 20:03:03 +01:00
Joachim Nilsson 02a42a1cad Add support for fopenf(), formatted string fopen()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-10 09:07:56 +01:00
Joachim Nilsson 28c11f010a Check for existence of AM_PROG_AR macro
This patch facilitates building newer versions of libite on systems with
older versions of autoconf and automake.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 15:47:28 +01:00
61 changed files with 1556 additions and 148 deletions

No files matched your search

+23 -4
View File
@@ -10,11 +10,30 @@ compiler:
- gcc - gcc
- clang - clang
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "EcWeDUONZnl7IHBWD2rc92LwTWGIlqBZ7wQrLfe3mFXOnB+IZjJIBnDsJDnHDWwA8fGF9NaJbRz4BThroafueUwkDXNyvph1Mdaxm6mdMPyjNJ4H1AFkd9Fz0LYdLNXCPl43tm6s1BR6OWts17lWF6sMnMmIu8gUgXJVg2qsDBl3O9eCoRvQ/h4elLfXZ03fHi4XzzzQvZVyDCg8MCzXIgHJzdkv4llpiCLWQExFbIAVy39euDnx+UuWYB7WDdUbOc7HkkUwf0/vX9PhKVQFKOkXn1ddN0iCsWRH3ti5KXWrBeRO3RPu6Z5YtR8l1WK7iqCYOLuMBW23tXsBQsIW09f1+fFgJ8Ig5hHRRbDinbTUb+mHUJZmNv9ZTc3hPYH4Fyev/ljk42VVDdIBy9AqO42jj8VGmDmiIq47aqNJZUGYZgQlGXGqk9MtavJrqEVcFSgyfEtI+c4n4fzvMRpcEwjnbp482s1xNzHQZ1GQI77Td5UUXXWyNSCoQoE/VpkAesYJAw8KwXOXveDr3Qu0HhuQu1oyLmWHlZHYDu+TInjY81gpGw9Cm7/SdFoA0Ag49PlAXdPRymbP01B50MqrCTxtXEHtdXxhrkDvaoUp7heSuvO0fS+mI5F7eQ4Ji2JdyRSt1KpXVNAyL1FrO/yznM3EwcXPmWmrc+QjFtC9vY4="
before_install:
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
addons:
coverity_scan:
project:
name: "troglobit/libite"
description: "That missing frog DNA you've been looking for"
notification_email: troglobit@gmail.com
build_command_prepend: "./autogen.sh && ./configure --prefix= --disable-silent-rules"
build_command: "make clean all"
branch_pattern: dev
script: script:
- ./autogen.sh - ./autogen.sh
- ./configure --prefix=/tmp --disable-silent-rules - ./configure --prefix= --disable-silent-rules
- make clean - make clean
- make -j5 - make -j5
- make install-strip - make install-strip DESTDIR=/tmp/foo
- ls -lR /tmp - ls -lR /tmp/foo
- make check - make distcheck
+62 -1
View File
@@ -3,6 +3,62 @@ Change Log
All notable changes to the project are documented in this file. All notable changes to the project are documented in this file.
[v2.4.0][] - 2021-03-27
-----------------------
### Changes
- Add support for `touchf()`, formatted string support for `touch()`
- Add support for `erasef()`, formatted string support for `erase()`
- Add support for `strtrim()`, trims leading and trailing white-space
from a string
### Fixes
- Fix `systemf()` improper handling of `system()` return value. Now
checks if exited OK, then returning the exit status of the command, or
if not exited OK, then checks if the command was signaled, and returns
-1 with `errno` set. This also allows for returning 127, like
`system()`, if the shell, or the program itself, did not exist
[v2.3.1][] - 2021-02-12
-----------------------
### Changes
- Copyright updates, including LICENSE file, year + author last name
### Fixes
- Debian packaging fixes only
[v2.3.0][] - 2021-02-12
-----------------------
### Changes
- Add support for `fremove()`, formatted `remove()` replacement
- Add support for `truncatef()`, formatted `truncate()` replacement
- Add tar.gz archives to distribution
### Fixes
- Handle `ETIMEDOUT` error for `connect()` call in `telnet_open()`
[v2.2.0][] - 2020-03-16
-----------------------
### Changes
- Add support for `systemf()`, formatted string `system()` replacement
- Add support for `fmkpath()`, formatted string `mkpath()`
- Add support for `fopenf()`, formatted string `fopen()` replacement
### Fixes
- Fix possible memory leak in `rsync()`, found by Coverity Scan
- Check return value of `fstat()` to prevent bogus destination file
times when using `copyfile()`, found by Coverity Scan
[v2.1.2][] - 2020-02-22 [v2.1.2][] - 2020-02-22
----------------------- -----------------------
@@ -357,7 +413,12 @@ problems this may cause!
Initial extraction of frog DNA from [Finit][]. See [README][] for API details. Initial extraction of frog DNA from [Finit][]. See [README][] for API details.
[UNRELEASED]: https://github.com/troglobit/libite/compare/v2.1.2...HEAD [UNRELEASED]: https://github.com/troglobit/libite/compare/v2.4.0...HEAD
[v2.4.0]: https://github.com/troglobit/libite/compare/v2.3.1...v2.4.0
[v2.3.1]: https://github.com/troglobit/libite/compare/v2.3.0...v2.3.1
[v2.3.0]: https://github.com/troglobit/libite/compare/v2.2.1...v2.3.0
[v2.2.1]: https://github.com/troglobit/libite/compare/v2.2.0...v2.2.1
[v2.2.0]: https://github.com/troglobit/libite/compare/v2.1.2...v2.2.0
[v2.1.2]: https://github.com/troglobit/libite/compare/v2.1.1...v2.1.2 [v2.1.2]: https://github.com/troglobit/libite/compare/v2.1.1...v2.1.2
[v2.1.1]: https://github.com/troglobit/libite/compare/v2.1.0...v2.1.1 [v2.1.1]: https://github.com/troglobit/libite/compare/v2.1.0...v2.1.1
[v2.1.0]: https://github.com/troglobit/libite/compare/v2.0.2...v2.1.0 [v2.1.0]: https://github.com/troglobit/libite/compare/v2.0.2...v2.1.0
+1 -7
View File
@@ -1,5 +1,5 @@
Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com> Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com> Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -18,9 +18,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
Note: Much of the code in libite (-lite) is written by Claudio Matsuoka
for Finit and released under the MIT/X11 license. Joachim Nilsson
later improved on the Finit code base and included pieces of
software released under the ISC and BSD licenses. See each
respective file for license details.
+14 -16
View File
@@ -6,13 +6,6 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libite.pc pkgconfig_DATA = libite.pc
SUBDIRS = src tests SUBDIRS = src tests
## Generate MD5 checksum file
MD5 = md5sum
md5-dist:
@for file in $(DIST_ARCHIVES); do \
$(MD5) $$file > ../$$file.md5; \
done
## Check if tagged in git ## Check if tagged in git
release-hook: release-hook:
@if [ ! `git tag | grep $(PACKAGE_VERSION)` ]; then \ @if [ ! `git tag | grep $(PACKAGE_VERSION)` ]; then \
@@ -31,20 +24,25 @@ release-hook:
echo; \ echo; \
fi fi
# lintian --profile debian -i -I --show-overrides ../$PKG.changes ## Generate .deb package
package build-deb: package:
@dpkg-buildpackage -uc -us -B @debuild -uc -us -B --lintian-opts --profile debian -i -I --show-overrides
## Target to run when building a release ## Target to run when building a release
release: release-hook distcheck package md5-dist release: release-hook distcheck package
@for file in $(DIST_ARCHIVES); do \
md5sum $$file > ../$$file.md5; \
sha256sum $$file > ../$$file.sha256; \
done
@mv $(DIST_ARCHIVES) ../ @mv $(DIST_ARCHIVES) ../
@echo @echo
@echo "Resulting release files:" @echo "Resulting release files:"
@echo "=================================================================" @echo "================================================================="
@for file in $(DIST_ARCHIVES); do \ @for file in $(DIST_ARCHIVES); do \
printf "%-32s Distribution tarball\n" $$file; \ printf "%-32s Distribution tarball\n" $$file; \
printf "%-32s " $$file.md5; cat ../$$file.md5 | cut -f1 -d' '; \ printf "%-32s " $$file.md5; cat ../$$file.md5 | cut -f1 -d' '; \
printf "%-32s " $$file.sha256; cat ../$$file.sha256 | cut -f1 -d' '; \
done done
@for file in `cd ..; ls $(PACKAGE)*_$(VERSION)*`; do \ @for file in `cd ..; ls $(PACKAGE)*_$(VERSION)*`; do \
printf "%-32s Debian/Ubuntu package\n" $$file; \ printf "%-32s Debian/Ubuntu package\n" $$file; \
done done
+71 -9
View File
@@ -1,7 +1,6 @@
-lite | Frog DNA, basically -lite | Frog DNA, basically
=========================== ===========================
[![Travis Status][]][Travis] [![Travis Status][]][Travis] [![Coverity Status]][Coverity Scan]
Table of Contents Table of Contents
----------------- -----------------
@@ -12,7 +11,7 @@ Table of Contents
* [Generic Functions](#generic-functions) * [Generic Functions](#generic-functions)
* [OpenBSD Functions](#openbsd-functions) * [OpenBSD Functions](#openbsd-functions)
* [Build & Install](#origin--references) * [Build & Install](#origin--references)
* [TODO](#todo) * [Origin & References](#origin--references)
> **NOTE:** Incompatible changes in v2.0 compared to v1.x! > **NOTE:** Incompatible changes in v2.0 compared to v1.x!
@@ -95,6 +94,10 @@ Helper Macros
Erase file/directory with `remove()`. Errors on `stderr` Erase file/directory with `remove()`. Errors on `stderr`
- `erasef(fmt, ...)`
Like `erase()` but takes a formatted printf-like string as argument.
- `makedir(path)` - `makedir(path)`
Create directory, like `mkdir()`. Errors on `stderr` Create directory, like `mkdir()`. Errors on `stderr`
@@ -111,6 +114,10 @@ Helper Macros
Create a file, or update mtime. Errors on `stderr` Create a file, or update mtime. Errors on `stderr`
- `touchf(fmt, ...)`
Like `touch()` but takes a formatted printf-like string as argument.
- `S_ISEXEC(mode_t m)` - `S_ISEXEC(mode_t m)`
Mysteriously missing from GLIBC Mysteriously missing from GLIBC
@@ -181,6 +188,22 @@ Generic Functions
Check for the existence of a directory, returns True(1) or False(0). Check for the existence of a directory, returns True(1) or False(0).
- `fopenf(mode, fmt, ...)`
Like `fopen()`, but takes a formatted string as argument. This
greatly simplifies operations that usually consist of composing a
filename from parts into a dynamic buffer before actually opening
the file.
> **Notice:** the swapped order of `pathname` and `mode`!
- `fremove(fmt, ...)`
Like `remove()`, but takes a formatted string as argument. This
greatly simplifies operations that usually consist of composing a
filename from parts into a dynamic buffer before actually removing
the file.
- `fsendfile(src, dst, len)` - `fsendfile(src, dst, len)`
Copy data between file streams, very similar to `fcopyfile()`, but Copy data between file streams, very similar to `fcopyfile()`, but
@@ -223,6 +246,12 @@ Generic Functions
Like `makepath()`, but also takes a `mode_t` permission mode argument. Like `makepath()`, but also takes a `mode_t` permission mode argument.
- `fmkpath(mode, fmt, ...)`
Like `mkpath()`, but takes a formatted string as argument.
> **Notice:** the swapped order of `pathname` and `mode`!
- `movefile(src, dst)` - `movefile(src, dst)`
Like `copyfile()`, but renames `src` to `dst`, or recreates symlink Like `copyfile()`, but renames `src` to `dst`, or recreates symlink
@@ -284,17 +313,29 @@ Generic Functions
`delete`, it is now called `opt`. The APIs are 100% compatible if the `delete`, it is now called `opt`. The APIs are 100% compatible if the
value `1` was used. value `1` was used.
- `strmatch()`, `strnmatch()` - `strmatch(str, list)`, `strnmatch(str, list, len)`
Find matching string in an array of strings. Returns index in array Find matching string in an array of strings. Returns index in array on
on match, or `-1` on error or not found. match, or `-1` on error or not found. `strnmatch()` takes an extra arg
to compare only `len` number of characters from `str`.
- `telnet_open(), telnet_close(), telnet_expect()` - `strtrim(str)`
Trims a string from any leading and trailing white-space, returns the
trimmed result in the same buffer.
- `systemf(fmt, ...)`
Like `system()`, but takes a formatted string as argument. This
greatly simplifies operations that usually consist of composing a
command from parts into a dynamic buffer before calling it.
- `telnet_open(addr, port), telnet_close(ctx), telnet_expect(ctx, script, output)`
Poor mans telnet expect in C. Opens connection to a Telnet service; Poor mans telnet expect in C. Opens connection to a Telnet service;
FTP, Telnet, similar, and run an expect-like script. FTP, Telnet, similar, and run an expect-like script.
- `telnet_session()` - `telnet_session(addr, port, script output)`
Wrapper for the above three in one API. Wrapper for the above three in one API.
@@ -307,6 +348,13 @@ Generic Functions
**Note:** Requires Linux v3.11, or later, will fall back to the old **Note:** Requires Linux v3.11, or later, will fall back to the old
and unsafe `tmpfile()` on older systems. and unsafe `tmpfile()` on older systems.
- `truncatef(length, fmt, ...)`
Like `truncate()`, but takes a formatted string as argument. This
simplifies some operations when the filename otherwise have to be
composed from parts into a separate array before calling the real
function.
- `which(cmd)`, `whichp(cmd)` - `which(cmd)`, `whichp(cmd)`
C implementation of UNIX which(1). Returns a malloc'ed string with the C implementation of UNIX which(1). Returns a malloc'ed string with the
@@ -408,6 +456,15 @@ to generate a `configure` script. It is a generated file and otherwise
only included in released tarballs. only included in released tarballs.
Origin & References
-------------------
Much of the code in libite (-lite) is written by [Claudio Matsuoka][]
for [Finit][original finit] and released under the MIT/X11 license.
Joachim Wiberg later improved on the [Finit][] code base and included
pieces of software released under the ISC and BSD licenses. See each
respective file for license details.
[1]: https://github.com/troglobit/finit [1]: https://github.com/troglobit/finit
[2]: http://www.openbsd.org/ [2]: http://www.openbsd.org/
[3]: http://www.openbsd.org/cgi-bin/man.cgi?query=strlcpy [3]: http://www.openbsd.org/cgi-bin/man.cgi?query=strlcpy
@@ -418,4 +475,9 @@ only included in released tarballs.
[ISC]: https://en.wikipedia.org/wiki/ISC_license [ISC]: https://en.wikipedia.org/wiki/ISC_license
[BSD]: https://en.wikipedia.org/wiki/BSD_licenses [BSD]: https://en.wikipedia.org/wiki/BSD_licenses
[Travis]: https://travis-ci.org/troglobit/libite [Travis]: https://travis-ci.org/troglobit/libite
[Travis Status]: https://travis-ci.org/troglobit/libite.png?branch=master [Travis Status]: https://travis-ci.org/troglobit/libite.svg?branch=master
[Coverity Scan]: https://scan.coverity.com/projects/20602
[Coverity Status]: https://img.shields.io/coverity/scan/20602.svg
[Claudio Matsuoka]: https://github.com/cmatsuoka
[original finit]: http://helllabs.org/finit/
[Finit]: https://github.com/troglobit/finit
+3 -3
View File
@@ -1,6 +1,6 @@
AC_INIT(libite, 2.1.2, https://github.com/troglobit/libite/issues) AC_INIT(libite, 2.4.0, https://github.com/troglobit/libite/issues)
AC_CONFIG_AUX_DIR(aux) AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz]) AM_INIT_AUTOMAKE([1.11 foreign dist-xz])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR(src/lite.h) AC_CONFIG_SRCDIR(src/lite.h)
@@ -10,7 +10,7 @@ AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC AC_PROG_CC
AC_PROG_INSTALL AC_PROG_INSTALL
AM_PROG_AR m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_INIT LT_INIT
AC_OUTPUT AC_OUTPUT
+1
View File
@@ -2,6 +2,7 @@
*.substvars *.substvars
.debhelper/* .debhelper/*
tmp/* tmp/*
libite/*
libite5/* libite5/*
libite-dev/* libite-dev/*
autoreconf* autoreconf*
+44
View File
@@ -1,3 +1,47 @@
libite (2.4.0) stable; urgency=medium
* New functions:
- touchf(), formatted string support for touch()
- erasef(), formatted string support for erase()
- strtrim(), trims leading and trailing white-space from a string
* Fix systemf() improper handling of system() return value. Now checks
if exited OK, then returning the exit status of the command, or if not
exited OK, then checks if the command was signaled, and returns -1 with
errno set. This also allows for returning 127, like system(), if the
shell, or the program itself, did not exist.
-- Joachim Wiberg <troglobit@gmail.com> Sat, 27 Mar 2021 09:12:32 +0100
libite (2.3.1) stable; urgency=medium
* Minor packaging fixes.
* Copyright updates, including LICENSE file, year + author last name
-- Joachim Wiberg <troglobit@gmail.com> Fri, 12 Feb 2021 15:10:42 +0100
libite (2.3.0) stable; urgency=medium
* New functions:
- Add support for fremove(), formatted remove() replacement
- Add support for truncatef(), formatted truncate() replacement
* Fixes
- Handle ETIMEDOUT error for connect() call in telnet_open()
-- Joachim Wiberg <troglobit@gmail.com> Fri, 12 Feb 2021 08:03:47 +0100
libite (2.2.0) stable; urgency=medium
* New functions:
- systemf(), formatted string system() replacement
- fmkpath(), formatted string mkpath() replacement
- fopenf(), formatted string fopen() replacement
* Fixes
- possible memory leak in rsync()
- Check return value of fstat() to prevent bogus destination file
times when using copyfile()
-- Joachim Nilsson <troglobit@gmail.com> Mon, 16 Mar 2020 15:42:02 +0100
libite (2.1.2) stable; urgency=high libite (2.1.2) stable; urgency=high
* Fix upgrade of base package, new library name to match SONAME * Fix upgrade of base package, new library name to match SONAME
+2 -2
View File
@@ -1,7 +1,7 @@
Source: libite Source: libite
Priority: optional Priority: optional
Maintainer: Joachim Nilsson <troglobit@gmail.com> Maintainer: Joachim Wiberg <troglobit@gmail.com>
Build-Depends: debhelper (>= 10) Build-Depends: debhelper (>= 10), libtool
Standards-Version: 4.3.0 Standards-Version: 4.3.0
Section: libs Section: libs
Homepage: https://github.com/troglobit/libite/ Homepage: https://github.com/troglobit/libite/
+44 -12
View File
@@ -4,7 +4,7 @@ Source: https.//github.com/troglobit/libite/
Files: * Files: *
Copyright: Copyright:
2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com> 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
2008-2020 Joachim Nilsson <troglobit@gmail.com> 2008-2021 Joachim Wiberg <troglobit@gmail.com>
License: MIT License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -25,25 +25,49 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
Files: chomp.c Files: chomp.c
Copyright: 2014-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2014-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: conio.h Files: conio.?
Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: dir.c Files: dir.c
Copyright: 2008-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2008-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: fopenf.c fremove.c systemf.c truncatef.c
Copyright: 2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC
Files: fparseln.c
Copyright: 1997 Christos Zoulas
License: BSD-2-clause
Files: fsendfile.c
Copyright: 2013 Tobias Waldekranz <tobias@waldekranz.com>
License: MIT
Files: lfile.c Files: lfile.c
Copyright: 2015-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2015-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC
Files: makepath.c
Copyright: 2016-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: pidfile.c Files: pidfile.c
Copyright: 1999 The NetBSD Foundation, Inc. Copyright: 1999 The NetBSD Foundation, Inc.
License: BSD-2-clause License: BSD-2-clause
Files: pidfilefn.c
Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC
Files: progress.c
Copyright: 2012-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC
Files: queue.h Files: queue.h
Copyright: 1991, 1993 The Regents of the University of California. Copyright: 1991, 1993 The Regents of the University of California.
License: BSD-3-clause License: BSD-3-clause
@@ -53,7 +77,7 @@ Copyright: 2008 Otto Moerbeek <otto@drijf.net>
License: ISC License: ISC
Files: rsync.c Files: rsync.c
Copyright: 2011-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2011-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: strdupa.h strndupa.h Files: strdupa.h strndupa.h
@@ -64,12 +88,16 @@ Files: strlcat.c strlcpy.c
Copyright: 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com> Copyright: 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
License: MIT License: MIT
Files: strlite.h
Copyright: 2008-2021 Joachim Wiberg <troglobit@gmail.com>
License: MIT
Files: strmatch.c Files: strmatch.c
Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: strnlen.c Files: strnlen.c
Copyright: 2016-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2016-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: strtonum.c Files: strtonum.c
@@ -77,19 +105,23 @@ Copyright: 2004 Ted Unangst and Todd Miller
License: ISC License: ISC
Files: telnet.c Files: telnet.c
Copyright: 2010-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2010-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: tempfile.c Files: tempfile.c
Copyright: 2015-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2015-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: tree.h Files: tree.h
Copyright: 2002 Niels Provos <provos@citi.umich.edu> Copyright: 2002 Niels Provos <provos@citi.umich.edu>
License: BSD-2-clause License: BSD-2-clause
Files: which.c
Copyright: 2017-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC
Files: yorn.c Files: yorn.c
Copyright: 2009-2020 Joachim Nilsson <troglobit@gmail.com> Copyright: 2009-2021 Joachim Wiberg <troglobit@gmail.com>
License: ISC License: ISC
Files: tests/*.c Files: tests/*.c
+8
View File
@@ -5,11 +5,15 @@ libite.so.5 libite5 #MINVER#
chomp@Base 2.0.0 chomp@Base 2.0.0
copyfile@Base 2.0.0 copyfile@Base 2.0.0
dir@Base 2.0.0 dir@Base 2.0.0
erasef@Base 2.4.0
fcopyfile@Base 2.0.0 fcopyfile@Base 2.0.0
fexist@Base 2.0.0 fexist@Base 2.0.0
fgetint@Base 2.0.0 fgetint@Base 2.0.0
fisdir@Base 2.0.0 fisdir@Base 2.0.0
fmkpath@Base 2.2.0
fopenf@Base 2.2.0
fparseln@Base 2.0.0 fparseln@Base 2.0.0
fremove@Base 2.3.0
fsendfile@Base 2.0.0 fsendfile@Base 2.0.0
ifconfig@Base 2.0.0 ifconfig@Base 2.0.0
initscr@Base 2.0.0 initscr@Base 2.0.0
@@ -35,11 +39,15 @@ libite.so.5 libite5 #MINVER#
strmatch@Base 2.1.0 strmatch@Base 2.1.0
strnmatch@Base 2.1.0 strnmatch@Base 2.1.0
strtonum@Base 2.1.0 strtonum@Base 2.1.0
strtrim@Base 2.4.0
systemf@Base 2.2.0
telnet_close@Base 2.1.0 telnet_close@Base 2.1.0
telnet_expect@Base 2.1.0 telnet_expect@Base 2.1.0
telnet_open@Base 2.1.0 telnet_open@Base 2.1.0
telnet_session@Base 2.1.0 telnet_session@Base 2.1.0
tempfile@Base 2.0.0 tempfile@Base 2.0.0
touchf@Base 2.4.0
truncatef@Base 2.3.0
which@Base 2.0.0 which@Base 2.0.0
whichp@Base 2.0.0 whichp@Base 2.0.0
yorn@Base 2.1.0 yorn@Base 2.1.0
+5 -6
View File
@@ -1,15 +1,14 @@
#!/usr/bin/make -f #!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Uncomment this to turn on verbose mode. # Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1 #export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%: %:
dh $@ --with autoreconf dh $@ --with autoreconf
override_dh_auto_install:
dh_auto_install
-rm -f debian/libite/usr/share/doc/libite/LICENSE
override_dh_installchangelogs: override_dh_installchangelogs:
dh_installchangelogs ChangeLog.md dh_installchangelogs ChangeLog.md
override_dh_auto_install:
dh_auto_install
find debian -name LICENSE -delete
+6 -5
View File
@@ -2,19 +2,20 @@ lib_LTLIBRARIES = libite.la
libite_la_CPPFLAGS = -D_GNU_SOURCE libite_la_CPPFLAGS = -D_GNU_SOURCE
libite_la_CFLAGS = -W -Wall -Wextra libite_la_CFLAGS = -W -Wall -Wextra
libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 5:1:0 libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 8:0:3
libite_la_SOURCES = chomp.c copyfile.c \ libite_la_SOURCES = chomp.c copyfile.c \
conio.c conio.h \ conio.c conio.h dir.c \
dir.c \ erasef.c fopenf.c fremove.c \
fexist.c fisdir.c \ fexist.c fisdir.c \
fparseln.c fsendfile.c \ fparseln.c fsendfile.c \
ifconfig.c lfile.c \ ifconfig.c lfile.c \
makepath.c progress.c \ makepath.c progress.c \
pidfile.c pidfilefn.c \ pidfile.c pidfilefn.c \
reallocarray.c rsync.c \ reallocarray.c rsync.c strtrim.c \
strlcpy.c strlcat.c strtonum.c \ strlcpy.c strlcat.c strtonum.c \
strdupa.h strndupa.h strnlen.h \ strdupa.h strndupa.h strnlen.h \
strmatch.c telnet.c tempfile.c \ strmatch.c systemf.c touchf.c \
telnet.c tempfile.c truncatef.c \
yorn.c which.c \ yorn.c which.c \
lite.h strlite.h \ lite.h strlite.h \
queue.h tree.h queue.h tree.h
+1 -1
View File
@@ -1,6 +1,6 @@
/* Perl inspired chomp() implementation. /* Perl inspired chomp() implementation.
* *
* Copyright (c) 2014-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2014-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* A conio.h like implementation for VTANSI displays. /* A conio.h like implementation for VTANSI displays.
* *
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* A conio.h like implementation for VTANSI displays. /* A conio.h like implementation for VTANSI displays.
* *
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+3 -1
View File
@@ -85,7 +85,9 @@ static void set_mtime(int in, int out)
struct stat st; struct stat st;
struct timespec tv[2]; struct timespec tv[2];
fstat(in, &st); if (fstat(in, &st))
return;
tv[0] = st.st_atim; tv[0] = st.st_atim;
tv[1] = st.st_mtim; tv[1] = st.st_mtim;
futimens(out, tv); futimens(out, tv);
+1 -1
View File
@@ -1,6 +1,6 @@
/* Functions for operating on files in directories. /* Functions for operating on files in directories.
* *
* Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+66
View File
@@ -0,0 +1,66 @@
/* Formatted erase()
*
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include "lite.h"
/**
* erasef - Like erase() but with formatted string support
* @fmt: Formatted string to be composed into a pathname
*
* This is a wrapper for the erase() function in lite.h, lessening the
* burden of having to compose the filename from parts in a seprate
* buffer.
*
* Returns:
* Upon successful completion erasef() returns POSIX OK(0), otherwise,
* -1 is returned and errno is set to indicate the error.
*/
int erasef(const char *fmt, ...)
{
va_list ap;
char *file;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
file = alloca(len + 1);
if (!file) {
errno = ENOMEM;
return -1;
}
va_start(ap, fmt);
vsnprintf(file, len + 1, fmt, ap);
va_end(ap);
return erase(file);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+63
View File
@@ -0,0 +1,63 @@
/* Formatted fopen()
*
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
/**
* fopenf - Open a file based on the formatted string and optional arguments
* @mode: Last argument in optional list, if omitted EINVAL
* @fmt: Formatted string to be composed into a pathname
*
* This function is an extension to the fopen() family, lessening the burden
* of first having to compose the filename from parts in a seprate buffer.
*
* Returns:
* Upon successful completion fopenf() a FILE pointer. Otherwise, NULL
* is returned and errno is set to indicate the error.
*/
FILE *fopenf(const char *mode, const char *fmt, ...)
{
va_list ap;
char *file;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
file = alloca(len + 1);
if (!file) {
errno = ENOMEM;
return NULL;
}
va_start(ap, fmt);
vsnprintf(file, len + 1, fmt, ap);
va_end(ap);
return fopen(file, mode);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+61
View File
@@ -0,0 +1,61 @@
/* Formatted fremove()
*
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
/**
* fremove - Remove a file based on the formatted string and optional arguments
* @fmt: Formatted string to be composed into a pathname
*
* This function is an extension to remove(), lessening the burden of
* first having to compose the filename from parts in a seprate buffer.
*
* Returns:
* Return value for remove(3).
*/
int fremove(const char *fmt, ...)
{
va_list ap;
char *file;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
file = alloca(len + 1);
if (!file) {
errno = ENOBUFS;
return -1;
}
va_start(ap, fmt);
vsnprintf(file, len + 1, fmt, ap);
va_end(ap);
return remove(file);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+1 -1
View File
@@ -1,7 +1,7 @@
/* Fastinit (finit) ifconfig() implementation. /* Fastinit (finit) ifconfig() implementation.
* *
* Copyright (c) 2008-2010 Claudio Matsuoka <http://helllabs.org/finit/> * Copyright (c) 2008-2010 Claudio Matsuoka <http://helllabs.org/finit/>
* Copyright (C) 2009-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (C) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,6 +1,6 @@
/* Parse UNIX /etc configuration files like /etc/protocols and /etc/services /* Parse UNIX /etc configuration files like /etc/protocols and /etc/services
* *
* Copyright (c) 2015-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2015-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+15 -4
View File
@@ -1,7 +1,7 @@
/* Collection of frog DNA /* Collection of frog DNA
* *
* Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com> * Copyright (c) 2008-2010 Claudio Matsuoka <cmatsuoka@gmail.com>
* Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -60,16 +60,22 @@ typedef struct lfile lfile_t;
typedef struct sdbuf sdbuf_t; typedef struct sdbuf sdbuf_t;
char *chomp (char *str); char *chomp (char *str);
int erasef (const char *fmt, ...);
char *fparseln (FILE *, size_t *, size_t *, const char[3], int); char *fparseln (FILE *, size_t *, size_t *, const char[3], int);
int fexist (const char *file); int fexist (const char *file);
int fisdir (const char *path); int fisdir (const char *path);
FILE *fopenf (const char *mode, const char *fmt, ...);
int fremove (const char *fmt, ...);
FILE *tempfile (void); FILE *tempfile (void);
ssize_t copyfile (const char *src, const char *dst, int len, int opt); ssize_t copyfile (const char *src, const char *dst, int len, int opt);
int movefile (const char *src, const char *dst); int movefile (const char *src, const char *dst);
int fcopyfile (FILE *src, FILE *dst); int fcopyfile (FILE *src, FILE *dst);
ssize_t fsendfile (FILE *src, FILE *dst, size_t len); ssize_t fsendfile (FILE *src, FILE *dst, size_t len);
int truncatef (off_t length, const char *fmt, ...);
int ifconfig (const char *ifname, const char *addr, const char *mask, int up); int ifconfig (const char *ifname, const char *addr, const char *mask, int up);
@@ -80,6 +86,7 @@ char *lfgetkey (lfile_t *lf, const char *key);
int lfgetint (lfile_t *lf, const char *key); int lfgetint (lfile_t *lf, const char *key);
int fgetint (const char *file, const char *sep, const char *key); int fgetint (const char *file, const char *sep, const char *key);
int fmkpath (mode_t mode, const char *fmt, ...);
int mkpath (const char *dir, mode_t mode); int mkpath (const char *dir, mode_t mode);
int makepath (const char *dir); int makepath (const char *dir);
@@ -96,11 +103,15 @@ void *reallocarray(void *optr, size_t nmemb, size_t size);
void progress (int percent, int max_width); void progress (int percent, int max_width);
void progress_simple(int percent); void progress_simple(int percent);
int systemf (const char *fmt, ...);
sdbuf_t*telnet_open (int addr, short port); sdbuf_t*telnet_open (int addr, short port);
int telnet_close (sdbuf_t *ctx); int telnet_close (sdbuf_t *ctx);
int telnet_expect (sdbuf_t *ctx, char *script[], FILE *output); int telnet_expect (sdbuf_t *ctx, char *script[], FILE *output);
int telnet_session (int addr, short port, char *script[], FILE *output); int telnet_session (int addr, short port, char *script[], FILE *output);
int touchf (const char *fmt, ...);
int yorn (const char *fmt, ...); int yorn (const char *fmt, ...);
char *which (const char *cmd); char *which (const char *cmd);
@@ -111,9 +122,9 @@ int whichp (const char *cmd);
#include <sys/time.h> /* utimensat() on *BSD */ #include <sys/time.h> /* utimensat() on *BSD */
static inline int touch(const char *path) static inline int touch(const char *path)
{ {
if (mknod((path), S_IFREG|0644, 0)) { if (utimensat(AT_FDCWD, path, NULL, 0)) {
if (errno == EEXIST) if (errno == ENOENT)
return utimensat(AT_FDCWD, path, NULL, 0); return mknod((path), S_IFREG|0644, 0);
return -1; return -1;
} }
return 0; return 0;
+37 -1
View File
@@ -1,6 +1,6 @@
/* mkpath() -- Create all components leading up to a given directory /* mkpath() -- Create all components leading up to a given directory
* *
* Copyright (c) 2013-2016 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2013-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@@ -17,6 +17,8 @@
#include <errno.h> #include <errno.h>
#include <libgen.h> #include <libgen.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include "lite.h" #include "lite.h"
@@ -46,6 +48,40 @@ int mkpath(const char *dir, mode_t mode)
return mkdir(dir, mode); return mkdir(dir, mode);
} }
/**
* fmkpath - Formatted version of mkpath()
* @mode: A &mode_t mode to create directories with
* @fmt: Formatted string to be composed into a pathname
*
* Note:
* Notice the swapped arguments, compared to mkpath()!
*
* Returns:
* POSIX OK(0) on success, otherwise -1 with @errno set.
*/
int fmkpath(mode_t mode, const char *fmt, ...)
{
va_list ap;
char *path;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
path = alloca(len + 1);
if (!path) {
errno = ENOMEM;
return -1;
}
va_start(ap, fmt);
len = vsnprintf(path, len + 1, fmt, ap);
va_end(ap);
return mkpath(path, mode);
}
/** /**
* makepath - Create all components of the specified directory. * makepath - Create all components of the specified directory.
* @dir: Directory to create. * @dir: Directory to create.
+1 -1
View File
@@ -1,6 +1,6 @@
/* Functions for dealing with PID files (client side) /* Functions for dealing with PID files (client side)
* *
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* Simple termios based progress bar /* Simple termios based progress bar
* *
* Copyright (c) 2012-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2012-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+8 -6
View File
@@ -1,6 +1,6 @@
/* Micro "rsync" implementation. /* Micro "rsync" implementation.
* *
* Copyright (c) 2011-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2011-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@@ -107,20 +107,22 @@ int rsync(char *src, char *dst, int opt, int (*filter)(const char *file))
snprintf(source, sizeof(source), "%s%s%s", src, fisslashdir(src) ? "" : "/", files[i]); snprintf(source, sizeof(source), "%s%s%s", src, fisslashdir(src) ? "" : "/", files[i]);
if (fisdir(source)) { if (fisdir(source)) {
char dst2[256]; char dst2[256];
struct stat st; struct stat sb;
strcat(source, "/"); strcat(source, "/");
if (stat(source, &st)) if (stat(source, &sb)) {
return 1; result++;
continue;
}
if (mdir(dst2, sizeof(dst2), dst, files[i], &st)) { if (mdir(dst2, sizeof(dst2), dst, files[i], &sb)) {
result++; result++;
continue; continue;
} }
rsync(source, dst2, opt, filter); rsync(source, dst2, opt, filter);
if (keep_mtim) if (keep_mtim)
set_mtime(dst2, &st); set_mtime(dst2, &sb);
continue; /* Next file/dir in @src to copy... */ continue; /* Next file/dir in @src to copy... */
} }
+4 -2
View File
@@ -1,6 +1,6 @@
/* Collection of frog DNA /* Collection of frog DNA
* *
* Copyright (c) 2008-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2008-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@@ -67,6 +67,8 @@ size_t strlcat (char *dst, const char *src, size_t siz);
long long strtonum (const char *numstr, long long minval, long long maxval, const char **errstrp); long long strtonum (const char *numstr, long long minval, long long maxval, const char **errstrp);
#endif #endif
char *strtrim (char *str);
/* Convert string to natural number (0-2147483647), returns -1 on error. */ /* Convert string to natural number (0-2147483647), returns -1 on error. */
static inline int atonum(const char *str) static inline int atonum(const char *str)
{ {
@@ -107,7 +109,7 @@ static inline int string_compare(const char *a, const char *b)
*/ */
static inline int string_case_compare(const char *a, const char *b) static inline int string_case_compare(const char *a, const char *b)
{ {
return strlen (a) == strlen (b) && !strcasecmp (a, b); return strlen(a) == strlen(b) && !strcasecmp(a, b);
} }
#endif /* LITE_STRING_H_ */ #endif /* LITE_STRING_H_ */
+1 -1
View File
@@ -1,6 +1,6 @@
/* Simple string matcher function, finds partial matches. /* Simple string matcher function, finds partial matches.
* *
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* strnlen.h - Re-implementation of GLIBC strnlen() /* strnlen.h - Re-implementation of GLIBC strnlen()
* *
* Copyright (c) 2016-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2016-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+70
View File
@@ -0,0 +1,70 @@
/* Trim a string from whitespace
*
* Copyright (c) 2014 Mattias Walström <lazzer@gmail.com>
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include "lite.h"
/**
* strtrim - Strip leading and trailing whitespace from a string
* @str: The string to trim
*
* Trims a string from any leading and trailing white-space, returns the
* trimmed result in the same buffer.
*
* Returns:
* If @str is a valid, non-NULL, string this function returns the same
* string stripped from whitespace. This function only returns %NULL
* if @str itself is %NULL.
*/
char *strtrim(char *str)
{
char *start, *end;
if (!str) {
errno = EINVAL;
return NULL;
}
start = str;
while (isspace(*start))
start++;
if (*start == 0) {
str[0] = 0;
return str;
}
end = start + strlen(start) - 1;
while (end > start && isspace(*end))
end--;
*(++end) = 0;
memmove(str, start, end - start + 1);
return str;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+65
View File
@@ -0,0 +1,65 @@
/* Formatted system() which returns actual return status of command
*
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
int systemf(const char *fmt, ...)
{
va_list ap;
char *cmd;
int len;
int rc;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
cmd = alloca(++len);
if (!cmd) {
errno = ENOMEM;
return -1;
}
va_start(ap, fmt);
vsnprintf(cmd, len, fmt, ap);
va_end(ap);
rc = system(cmd);
if (rc == -1)
return -1;
if (WIFEXITED(rc)) {
errno = 0;
rc = WEXITSTATUS(rc);
} else if (WIFSIGNALED(rc)) {
errno = EINTR;
rc = -1;
}
return rc;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+13 -6
View File
@@ -1,6 +1,6 @@
/* Poor mans telnet expect in C. /* Poor mans telnet expect in C.
* *
* Copyright (c) 2010-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2010-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@@ -44,7 +44,8 @@ sdbuf_t *telnet_open(int addr, short port)
struct sockaddr_in *sin; struct sockaddr_in *sin;
struct sockaddr s; struct sockaddr s;
sdbuf_t *ctx; sdbuf_t *ctx;
int saved_errno; int saved;
int retries = 10;
ctx = (sdbuf_t *)malloc(sizeof(sdbuf_t)); ctx = (sdbuf_t *)malloc(sizeof(sdbuf_t));
if (!ctx) { if (!ctx) {
@@ -61,24 +62,30 @@ sdbuf_t *telnet_open(int addr, short port)
ctx->sd = socket(PF_INET, SOCK_STREAM, 0); ctx->sd = socket(PF_INET, SOCK_STREAM, 0);
if (-1 == ctx->sd) { if (-1 == ctx->sd) {
saved_errno = errno; saved = errno;
// perror ("Failed creating socket"); // perror ("Failed creating socket");
free(ctx->buf); free(ctx->buf);
free(ctx); free(ctx);
errno = saved_errno; errno = saved;
return NULL; return NULL;
} }
retry:
sin = (struct sockaddr_in *)&s; sin = (struct sockaddr_in *)&s;
sin->sin_family = AF_INET; sin->sin_family = AF_INET;
sin->sin_port = port; sin->sin_port = port;
sin->sin_addr.s_addr = addr; sin->sin_addr.s_addr = addr;
if (-1 == connect(ctx->sd, &s, sizeof(s))) { if (-1 == connect(ctx->sd, &s, sizeof(s))) {
saved_errno = errno; if (ETIMEDOUT == errno && retries-- > 0) {
sleep(1);
goto retry;
}
saved = errno;
// perror ("Cannot connect to telnet daemon"); // perror ("Cannot connect to telnet daemon");
telnet_close(ctx); telnet_close(ctx);
errno = saved_errno; errno = saved;
return NULL; return NULL;
} }
+1 -1
View File
@@ -1,6 +1,6 @@
/* A secure tmpfile() replacement. /* A secure tmpfile() replacement.
* *
* Copyright (c) 2015-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2015-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+66
View File
@@ -0,0 +1,66 @@
/* Formatted touch()
*
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include "lite.h"
/**
* touchf - Like touch() but with formatted string support
* @fmt: Formatted string to be composed into a pathname
*
* This is a wrapper for the touch() function in lite.h, lessening the
* burden of having to compose the filename from parts in a seprate
* buffer.
*
* Returns:
* Upon successful completion touchf() returns POSIX OK(0), otherwise,
* -1 is returned and errno is set to indicate the error.
*/
int touchf(const char *fmt, ...)
{
va_list ap;
char *file;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
file = alloca(len + 1);
if (!file) {
errno = ENOMEM;
return -1;
}
va_start(ap, fmt);
vsnprintf(file, len + 1, fmt, ap);
va_end(ap);
return touch(file);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+64
View File
@@ -0,0 +1,64 @@
/* Formatted truncate()
*
* Copyright (c) 2021 Joachim Wiberg <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
/**
* truncatef - Truncate a file based on the formatted string
* @length: Size in bytes to truncate file to, zero to empty it
* @fmt: Formatted string to be composed into a pathname
*
* This is an extension to the truncate() family, lessening the burden
* of having to compose the filename from parts in a seprate buffer.
*
* Returns:
* Upon successful completion truncate() returns POSIX OK(0), otherwise,
* -1 is returned and errno is set to indicate the error.
*/
int truncatef(off_t length, const char *fmt, ...)
{
va_list ap;
char *file;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
file = alloca(len + 1);
if (!file) {
errno = ENOMEM;
return -1;
}
va_start(ap, fmt);
vsnprintf(file, len + 1, fmt, ap);
va_end(ap);
return truncate(file, length);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+1 -1
View File
@@ -1,6 +1,6 @@
/* C implementation of UNIX which(1) /* C implementation of UNIX which(1)
* *
* Copyright (c) 2017-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2017-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+1 -1
View File
@@ -1,6 +1,6 @@
/* Safe yes-or-no with prompt /* Safe yes-or-no with prompt
* *
* Copyright (c) 2009-2020 Joachim Nilsson <troglobit@gmail.com> * Copyright (c) 2009-2021 Joachim Wiberg <troglobit@gmail.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
+22 -19
View File
@@ -1,22 +1,25 @@
*.o *.o
*.log *.log
*.trs *.trs
chomp .deps/
copyfile /chomp
dir /copyfile
fexist /dir
fisdir /fexist
fsendfile /fisdir
lfile /fopenf
makepath /fsendfile
pidfile /lfile
printhdr /makepath
progress /pidfile
rsync /printhdr
str /progress
strmatch /rsync
tempfile /str
touch /strmatch
tree /systemf
which /tempfile
yorn /touch
/tree
/which
/yorn
+12 -1
View File
@@ -1,12 +1,22 @@
EXTRA_DIST = check.h EXTRA_DIST = check.h \
data/fexist/dir/.placeholder data/fexist/executable data/fexist/link \
data/fexist/regular data/lfile/fstab data/lfile/group data/lfile/passwd \
data/lfile/protocols data/lfile/services data/which/executable \
data/which/executable-link data/which/regular
CLEANFILES = *~ *.trs *.log CLEANFILES = *~ *.trs *.log
TESTS_ENVIRONMENT = ([ -d data ] || ln -sf $(srcdir)/data) &&
clean-local:
-find -type l -name data -exec rm {} \;
TESTS = TESTS =
TESTS += chomp TESTS += chomp
TESTS += copyfile TESTS += copyfile
TESTS += dir TESTS += dir
TESTS += fexist TESTS += fexist
TESTS += fisdir TESTS += fisdir
TESTS += fopenf
TESTS += fsendfile TESTS += fsendfile
TESTS += lfile TESTS += lfile
TESTS += makepath TESTS += makepath
@@ -16,6 +26,7 @@ TESTS += progress
TESTS += rsync TESTS += rsync
TESTS += str TESTS += str
TESTS += strmatch TESTS += strmatch
TESTS += systemf
TESTS += touch TESTS += touch
TESTS += tempfile TESTS += tempfile
TESTS += which TESTS += which
+1
View File
@@ -0,0 +1 @@
nonexistence
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+1
View File
@@ -0,0 +1 @@
regular
View File
Whitespace-only changes.
+3
View File
@@ -0,0 +1,3 @@
UUID=xxxxxxxxxx / xfs defaults 0 1
/dev/sda1 /boot/efi vfat umask=0077 0 1
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
+39
View File
@@ -0,0 +1,39 @@
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:
floppy:x:25:
tape:x:26:
sudo:x:27:
audio:x:29:
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:
sasl:x:45:
plugdev:x:46:
staff:x:50:
games:x:60:
users:x:100:
nogroup:x:65534:
+18
View File
@@ -0,0 +1,18 @@
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
+64
View File
@@ -0,0 +1,64 @@
# Internet (IP) protocols
#
# Updated from http://www.iana.org/assignments/protocol-numbers and other
# sources.
# New protocols will be added on request if they have been officially
# assigned by IANA and are not historical.
# If you need a huge list of used numbers please install the nmap package.
ip 0 IP # internet protocol, pseudo protocol number
hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883]
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # Internet Group Management
ggp 3 GGP # gateway-gateway protocol
ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
st 5 ST # ST datagram mode
tcp 6 TCP # transmission control protocol
egp 8 EGP # exterior gateway protocol
igp 9 IGP # any private interior gateway (Cisco)
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # user datagram protocol
hmp 20 HMP # host monitoring protocol
xns-idp 22 XNS-IDP # Xerox NS IDP
rdp 27 RDP # "reliable datagram" protocol
iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905]
dccp 33 DCCP # Datagram Congestion Control Prot. [RFC4340]
xtp 36 XTP # Xpress Transfer Protocol
ddp 37 DDP # Datagram Delivery Protocol
idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport
ipv6 41 IPv6 # Internet Protocol, version 6
ipv6-route 43 IPv6-Route # Routing Header for IPv6
ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6
idrp 45 IDRP # Inter-Domain Routing Protocol
rsvp 46 RSVP # Reservation Protocol
gre 47 GRE # General Routing Encapsulation
esp 50 IPSEC-ESP # Encap Security Payload [RFC2406]
ah 51 IPSEC-AH # Authentication Header [RFC2402]
skip 57 SKIP # SKIP
ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6
ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6
ipv6-opts 60 IPv6-Opts # Destination Options for IPv6
rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB)
vmtp 81 VMTP # Versatile Message Transport
eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco)
ospf 89 OSPFIGP # Open Shortest Path First IGP
ax.25 93 AX.25 # AX.25 frames
ipip 94 IPIP # IP-within-IP Encapsulation Protocol
etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378]
encap 98 ENCAP # Yet Another IP encapsulation [RFC1241]
# 99 # any private encryption scheme
pim 103 PIM # Protocol Independent Multicast
ipcomp 108 IPCOMP # IP Payload Compression Protocol
vrrp 112 VRRP # Virtual Router Redundancy Protocol [RFC5798]
l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661]
isis 124 ISIS # IS-IS over IPv4
sctp 132 SCTP # Stream Control Transmission Protocol
fc 133 FC # Fibre Channel
mobility-header 135 Mobility-Header # Mobility Support for IPv6 [RFC3775]
udplite 136 UDPLite # UDP-Lite [RFC3828]
mpls-in-ip 137 MPLS-in-IP # MPLS-in-IP [RFC4023]
manet 138 # MANET Protocols [RFC5498]
hip 139 HIP # Host Identity Protocol
shim6 140 Shim6 # Shim6 Protocol [RFC5533]
wesp 141 WESP # Wrapped Encapsulating Security Payload
rohc 142 ROHC # Robust Header Compression
+417
View File
@@ -0,0 +1,417 @@
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, officially ports have two entries
# even if the protocol doesn't support UDP operations.
#
# Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml .
#
# New ports will be added on request if they have been officially assigned
# by IANA and used in the real-world or are needed by a debian package.
# If you need a huge list of used numbers please install the nmap package.
tcpmux 1/tcp # TCP port service multiplexer
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
qotd 17/tcp quote
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp-data 20/tcp
ftp 21/tcp
fsp 21/udp fspd
ssh 22/tcp # SSH Remote Login Protocol
telnet 23/tcp
smtp 25/tcp mail
time 37/tcp timserver
time 37/udp timserver
whois 43/tcp nicname
tacacs 49/tcp # Login Host Protocol (TACACS)
tacacs 49/udp
domain 53/tcp # Domain Name Server
domain 53/udp
bootps 67/udp
bootpc 68/udp
tftp 69/udp
gopher 70/tcp # Internet Gopher
finger 79/tcp
http 80/tcp www # WorldWideWeb HTTP
kerberos 88/tcp kerberos5 krb5 kerberos-sec # Kerberos v5
kerberos 88/udp kerberos5 krb5 kerberos-sec # Kerberos v5
iso-tsap 102/tcp tsap # part of ISODE
acr-nema 104/tcp dicom # Digital Imag. & Comm. 300
pop3 110/tcp pop-3 # POP version 3
sunrpc 111/tcp portmapper # RPC 4.0 portmapper
sunrpc 111/udp portmapper
auth 113/tcp authentication tap ident
nntp 119/tcp readnews untp # USENET News Transfer Protocol
ntp 123/udp # Network Time Protocol
epmap 135/tcp loc-srv # DCE endpoint resolution
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp
imap2 143/tcp imap # Interim Mail Access P 2 and 4
snmp 161/tcp # Simple Net Mgmt Protocol
snmp 161/udp
snmp-trap 162/tcp snmptrap # Traps for SNMP
snmp-trap 162/udp snmptrap
cmip-man 163/tcp # ISO mgmt over IP (CMOT)
cmip-man 163/udp
cmip-agent 164/tcp
cmip-agent 164/udp
mailq 174/tcp # Mailer transport queue for Zmailer
xdmcp 177/udp # X Display Manager Control Protocol
bgp 179/tcp # Border Gateway Protocol
smux 199/tcp # SNMP Unix Multiplexer
qmtp 209/tcp # Quick Mail Transfer Protocol
z3950 210/tcp wais # NISO Z39.50 database
ipx 213/udp # IPX [RFC1234]
ptp-event 319/udp
ptp-general 320/udp
pawserv 345/tcp # Perf Analysis Workbench
zserv 346/tcp # Zebra server
rpc2portmap 369/tcp
rpc2portmap 369/udp # Coda portmapper
codaauth2 370/tcp
codaauth2 370/udp # Coda authentication server
clearcase 371/udp Clearcase
ldap 389/tcp # Lightweight Directory Access Protocol
ldap 389/udp
svrloc 427/tcp # Server Location
svrloc 427/udp
https 443/tcp # http protocol over TLS/SSL
snpp 444/tcp # Simple Network Paging Protocol
microsoft-ds 445/tcp # Microsoft Naked CIFS
microsoft-ds 445/udp
kpasswd 464/tcp
kpasswd 464/udp
submissions 465/tcp ssmtp smtps urd # Submission over TLS [RFC8314]
saft 487/tcp # Simple Asynchronous File Transfer
isakmp 500/udp # IPSEC key management
rtsp 554/tcp # Real Time Stream Control Protocol
rtsp 554/udp
nqs 607/tcp # Network Queuing system
asf-rmcp 623/udp # ASF Remote Management and Control Protocol
qmqp 628/tcp
ipp 631/tcp # Internet Printing Protocol
#
# UNIX specific services
#
exec 512/tcp
biff 512/udp comsat
login 513/tcp
who 513/udp whod
shell 514/tcp cmd syslog # no passwords used
syslog 514/udp
printer 515/tcp spooler # line printer spooler
talk 517/udp
ntalk 518/udp
route 520/udp router routed # RIP
gdomap 538/tcp # GNUstep distributed objects
gdomap 538/udp
uucp 540/tcp uucpd # uucp daemon
klogin 543/tcp # Kerberized `rlogin' (v5)
kshell 544/tcp krcmd # Kerberized `rsh' (v5)
dhcpv6-client 546/udp
dhcpv6-server 547/udp
afpovertcp 548/tcp # AFP over TCP
nntps 563/tcp snntp # NNTP over SSL
submission 587/tcp # Submission [RFC4409]
ldaps 636/tcp # LDAP over SSL
ldaps 636/udp
tinc 655/tcp # tinc control port
tinc 655/udp
silc 706/tcp
kerberos-adm 749/tcp # Kerberos `kadmin' (v5)
#
domain-s 853/tcp # DNS over TLS [RFC7858]
domain-s 853/udp # DNS over DTLS [RFC8094]
rsync 873/tcp
ftps-data 989/tcp # FTP over SSL (data)
ftps 990/tcp
telnets 992/tcp # Telnet over SSL
imaps 993/tcp # IMAP over SSL
pop3s 995/tcp # POP-3 over SSL
#
# From ``Assigned Numbers'':
#
#> The Registered Ports are not controlled by the IANA and on most systems
#> can be used by ordinary user processes or programs executed by ordinary
#> users.
#
#> Ports are used in the TCP [45,106] to name the ends of logical
#> connections which carry long term conversations. For the purpose of
#> providing services to unknown callers, a service contact port is
#> defined. This list specifies the port used by the server process as its
#> contact port. While the IANA can not control uses of these ports it
#> does register or list uses of these ports as a convienence to the
#> community.
#
socks 1080/tcp # socks proxy server
proofd 1093/tcp
rootd 1094/tcp
openvpn 1194/tcp
openvpn 1194/udp
rmiregistry 1099/tcp # Java RMI Registry
lotusnote 1352/tcp lotusnotes # Lotus Note
ms-sql-s 1433/tcp # Microsoft SQL Server
ms-sql-s 1433/udp
ms-sql-m 1434/tcp # Microsoft SQL Monitor
ms-sql-m 1434/udp
ingreslock 1524/tcp
datametrics 1645/tcp old-radius
datametrics 1645/udp old-radius
sa-msg-port 1646/tcp old-radacct
sa-msg-port 1646/udp old-radacct
kermit 1649/tcp
groupwise 1677/tcp
l2f 1701/udp l2tp
radius 1812/tcp
radius 1812/udp
radius-acct 1813/tcp radacct # Radius Accounting
radius-acct 1813/udp radacct
cisco-sccp 2000/tcp # Cisco SCCP
nfs 2049/tcp # Network File System
nfs 2049/udp # Network File System
gnunet 2086/tcp
gnunet 2086/udp
rtcm-sc104 2101/tcp # RTCM SC-104 IANA 1/29/99
rtcm-sc104 2101/udp
gsigatekeeper 2119/tcp
gris 2135/tcp # Grid Resource Information Server
cvspserver 2401/tcp # CVS client/server operations
venus 2430/tcp # codacon port
venus 2430/udp # Venus callback/wbc interface
venus-se 2431/tcp # tcp side effects
venus-se 2431/udp # udp sftp side effect
codasrv 2432/tcp # not used
codasrv 2432/udp # server port
codasrv-se 2433/tcp # tcp side effects
codasrv-se 2433/udp # udp sftp side effect
mon 2583/tcp # MON traps
mon 2583/udp
dict 2628/tcp # Dictionary server
f5-globalsite 2792/tcp
gsiftp 2811/tcp
gpsd 2947/tcp
gds-db 3050/tcp gds_db # InterBase server
icpv2 3130/tcp icp # Internet Cache Protocol
icpv2 3130/udp icp
isns 3205/tcp # iSNS Server Port
isns 3205/udp # iSNS Server Port
iscsi-target 3260/tcp
mysql 3306/tcp
ms-wbt-server 3389/tcp
nut 3493/tcp # Network UPS Tools
nut 3493/udp
distcc 3632/tcp # distributed compiler
distcc 3632/udp
daap 3689/tcp # Digital Audio Access Protocol
daap 3689/udp
svn 3690/tcp subversion # Subversion protocol
svn 3690/udp subversion
suucp 4031/tcp # UUCP over SSL
suucp 4031/udp
sysrqd 4094/tcp # sysrq daemon
sysrqd 4094/udp
sieve 4190/tcp # ManageSieve Protocol
epmd 4369/tcp # Erlang Port Mapper Daemon
epmd 4369/udp
remctl 4373/tcp # Remote Authenticated Command Service
remctl 4373/udp
f5-iquery 4353/tcp # F5 iQuery
f5-iquery 4353/udp
ipsec-nat-t 4500/udp # IPsec NAT-Traversal [RFC3947]
iax 4569/tcp # Inter-Asterisk eXchange
iax 4569/udp
mtn 4691/tcp # monotone Netsync Protocol
mtn 4691/udp
radmin-port 4899/tcp # RAdmin Port
radmin-port 4899/udp
sip 5060/tcp # Session Initiation Protocol
sip 5060/udp
sip-tls 5061/tcp
sip-tls 5061/udp
xmpp-client 5222/tcp jabber-client # Jabber Client Connection
xmpp-server 5269/tcp jabber-server # Jabber Server Connection
cfengine 5308/tcp
mdns 5353/udp # Multicast DNS
postgresql 5432/tcp postgres # PostgreSQL Database
freeciv 5556/tcp rptp # Freeciv gameplay
amqps 5671/tcp # AMQP protocol over TLS/SSL
amqp 5672/tcp
amqp 5672/udp
amqp 5672/sctp
x11 6000/tcp x11-0 # X Window System
x11-1 6001/tcp
x11-2 6002/tcp
x11-3 6003/tcp
x11-4 6004/tcp
x11-5 6005/tcp
x11-6 6006/tcp
x11-7 6007/tcp
gnutella-svc 6346/tcp # gnutella
gnutella-svc 6346/udp
gnutella-rtr 6347/tcp # gnutella
gnutella-rtr 6347/udp
sge-qmaster 6444/tcp sge_qmaster # Grid Engine Qmaster Service
sge-execd 6445/tcp sge_execd # Grid Engine Execution Service
mysql-proxy 6446/tcp # MySQL Proxy
babel 6696/udp # Babel Routing Protocol
ircs-u 6697/tcp # Internet Relay Chat via TLS/SSL
afs3-fileserver 7000/tcp bbs # file server itself
afs3-fileserver 7000/udp bbs
afs3-callback 7001/tcp # callbacks to cache managers
afs3-callback 7001/udp
afs3-prserver 7002/tcp # users & groups database
afs3-prserver 7002/udp
afs3-vlserver 7003/tcp # volume location database
afs3-vlserver 7003/udp
afs3-kaserver 7004/tcp # AFS/Kerberos authentication
afs3-kaserver 7004/udp
afs3-volser 7005/tcp # volume managment server
afs3-volser 7005/udp
afs3-errors 7006/tcp # error interpretation service
afs3-errors 7006/udp
afs3-bos 7007/tcp # basic overseer process
afs3-bos 7007/udp
afs3-update 7008/tcp # server-to-server updater
afs3-update 7008/udp
afs3-rmtsys 7009/tcp # remote cache manager service
afs3-rmtsys 7009/udp
font-service 7100/tcp xfs # X Font Service
http-alt 8080/tcp webcache # WWW caching service
puppet 8140/tcp # The Puppet master service
bacula-dir 9101/tcp # Bacula Director
bacula-fd 9102/tcp # Bacula File Daemon
bacula-sd 9103/tcp # Bacula Storage Daemon
xmms2 9667/tcp # Cross-platform Music Multiplexing System
nbd 10809/tcp # Linux Network Block Device
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
amanda 10080/tcp # amanda backup services
dicom 11112/tcp
hkp 11371/tcp # OpenPGP HTTP Keyserver
db-lsp 17500/tcp # Dropbox LanSync Protocol
dcap 22125/tcp # dCache Access Protocol
gsidcap 22128/tcp # GSI dCache Access Protocol
wnn6 22273/tcp # wnn6
#
# Datagram Delivery Protocol services
#
rtmp 1/ddp # Routing Table Maintenance Protocol
nbp 2/ddp # Name Binding Protocol
echo 4/ddp # AppleTalk Echo Protocol
zip 6/ddp # Zone Information Protocol
#=========================================================================
# The remaining port numbers are not as allocated by IANA.
#=========================================================================
# Kerberos (Project Athena/MIT) services
kerberos4 750/udp kerberos-iv kdc # Kerberos (server)
kerberos4 750/tcp kerberos-iv kdc
kerberos-master 751/udp kerberos_master # Kerberos authentication
kerberos-master 751/tcp
passwd-server 752/udp passwd_server # Kerberos passwd server
krb-prop 754/tcp krb_prop krb5_prop hprop # Kerberos slave propagation
zephyr-srv 2102/udp # Zephyr server
zephyr-clt 2103/udp # Zephyr serv-hm connection
zephyr-hm 2104/udp # Zephyr hostmanager
iprop 2121/tcp # incremental propagation
supfilesrv 871/tcp # Software Upgrade Protocol server
supfiledbg 1127/tcp # Software Upgrade Protocol debugging
#
# Services added for the Debian GNU/Linux distribution
#
poppassd 106/tcp # Eudora
poppassd 106/udp
moira-db 775/tcp moira_db # Moira database
moira-update 777/tcp moira_update # Moira update protocol
moira-ureg 779/udp moira_ureg # Moira user registration
spamd 783/tcp # spamassassin daemon
skkserv 1178/tcp # skk jisho server port
predict 1210/udp # predict -- satellite tracking
rmtcfg 1236/tcp # Gracilis Packeten remote config server
xtel 1313/tcp # french minitel
xtelw 1314/tcp # french minitel
support 1529/tcp # GNATS
cfinger 2003/tcp # GNU Finger
frox 2121/tcp # frox: caching ftp proxy
zebrasrv 2600/tcp # zebra service
zebra 2601/tcp # zebra vty
ripd 2602/tcp # ripd vty (zebra)
ripngd 2603/tcp # ripngd vty (zebra)
ospfd 2604/tcp # ospfd vty (zebra)
bgpd 2605/tcp # bgpd vty (zebra)
ospf6d 2606/tcp # ospf6d vty (zebra)
ospfapi 2607/tcp # OSPF-API
isisd 2608/tcp # ISISd vty (zebra)
afbackup 2988/tcp # Afbackup system
afbackup 2988/udp
afmbackup 2989/tcp # Afmbackup system
afmbackup 2989/udp
fax 4557/tcp # FAX transmission service (old)
hylafax 4559/tcp # HylaFAX client-server protocol (new)
distmp3 4600/tcp # distmp3host daemon
munin 4949/tcp lrrd # Munin
enbd-cstatd 5051/tcp # ENBD client statd
enbd-sstatd 5052/tcp # ENBD server statd
pcrd 5151/tcp # PCR-1000 Daemon
noclog 5354/tcp # noclogd with TCP (nocol)
noclog 5354/udp # noclogd with UDP (nocol)
hostmon 5355/tcp # hostmon uses TCP (nocol)
hostmon 5355/udp # hostmon uses UDP (nocol)
rplay 5555/udp # RPlay audio service
nrpe 5666/tcp # Nagios Remote Plugin Executor
nsca 5667/tcp # Nagios Agent - NSCA
mrtd 5674/tcp # MRT Routing Daemon
bgpsim 5675/tcp # MRT Routing Simulator
canna 5680/tcp # cannaserver
syslog-tls 6514/tcp # Syslog over TLS [RFC5425]
sane-port 6566/tcp sane saned # SANE network scanner daemon
ircd 6667/tcp # Internet Relay Chat
zope-ftp 8021/tcp # zope management by ftp
tproxy 8081/tcp # Transparent Proxy
omniorb 8088/tcp # OmniORB
omniorb 8088/udp
clc-build-daemon 8990/tcp # Common lisp build daemon
xinetd 9098/tcp
mandelspawn 9359/udp mandelbrot # network mandelbrot
git 9418/tcp # Git Version Control System
zope 9673/tcp # zope server
webmin 10000/tcp
kamanda 10081/tcp # amanda backup services (Kerberos)
amandaidx 10082/tcp # amanda backup services
amidxtape 10083/tcp # amanda backup services
smsqp 11201/tcp # Alamin SMS gateway
smsqp 11201/udp
xpilot 15345/tcp # XPilot Contact Port
xpilot 15345/udp
sgi-cmsd 17001/udp # Cluster membership services daemon
sgi-crsd 17002/udp
sgi-gcd 17003/udp # SGI Group membership daemon
sgi-cad 17004/tcp # Cluster Admin daemon
isdnlog 20011/tcp # isdn logging system
isdnlog 20011/udp
vboxd 20012/tcp # voice box system
vboxd 20012/udp
binkp 24554/tcp # binkp fidonet protocol
asp 27374/tcp # Address Search Protocol
asp 27374/udp
csync2 30865/tcp # cluster synchronization tool
dircproxy 57000/tcp # Detachable IRC Proxy
tfido 60177/tcp # fidonet EMSI over telnet
fido 60179/tcp # fidonet EMSI over TCP
# Local services
View File
Whitespace-only changes.
+1
View File
@@ -0,0 +1 @@
executable
View File
Whitespace-only changes.
+7 -4
View File
@@ -5,10 +5,13 @@ int main(void)
{ {
size_t i = 0; size_t i = 0;
struct { char *file; int exist; } arr[] = { struct { char *file; int exist; } arr[] = {
{ "/etc/passwd", 1 }, { "data/fexist/regular", 1 },
{ "/etc/kalle", 0 }, { "data/fexist/executable", 1 },
{ "/sbin/init", 1 }, { "data/fexist/link", 1 },
{ "/dev/null", 1 }, { "data/fexist/nonexistence", 0 },
{ "data/fexist/broken-link", 0 },
{ "data/fexist/dir", 1 },
{ "/dev/null", 1 },
{ NULL, 0 }, { NULL, 0 },
}; };
+25
View File
@@ -0,0 +1,25 @@
#include "check.h"
int main(void)
{
FILE *fp;
char *dir = "/tmp";
char *file = "__foo__";
printf("Pass 1/2: fopenf() ===========================\n");
fp = fopenf("w", "%s/%s", dir, file);
if (fp) {
fputs("foo", fp);
fclose(fp);
}
fail_unless(fexist("/tmp/__foo__"));
printf("Pass 2/2: fremove() ==========================\n");
fremove("%s/%s", dir, file);
fail_unless(!fexist("/tmp/__foo__"));
printf("DONE =========================================\n");
return 0;
}
+5 -5
View File
@@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include "check.h" #include "check.h"
#define FSTAB "/etc/fstab" #define FSTAB "data/lfile/fstab"
static int fstab(void) static int fstab(void)
{ {
@@ -42,28 +42,28 @@ int main(void)
{ {
int val; int val;
val = fgetint("/etc/protocols", " \n\t", "udp"); val = fgetint("data/lfile/protocols", " \n\t", "udp");
if (val == -1) { if (val == -1) {
perror("Failed locating 'udp' protocol"); perror("Failed locating 'udp' protocol");
return 1; return 1;
} }
printf("udp has proto %d\n", val); printf("udp has proto %d\n", val);
val = fgetint("/etc/services", " /\n\t", "ftp"); val = fgetint("data/lfile/services", " /\n\t", "ftp");
if (val == -1) { if (val == -1) {
perror("Failed locating 'ftp' service"); perror("Failed locating 'ftp' service");
return 1; return 1;
} }
printf("ftp is inet port %d\n", val); printf("ftp is inet port %d\n", val);
val = fgetint("/etc/group", "x:\n", "utmp"); val = fgetint("data/lfile/group", "x:\n", "utmp");
if (val == -1) { if (val == -1) {
perror("Failed locating group 'utmp'"); perror("Failed locating group 'utmp'");
return 1; return 1;
} }
printf("utmp is gid %d\n", val); printf("utmp is gid %d\n", val);
val = fgetint("/etc/passwd", "x:\n", "nobody"); val = fgetint("data/lfile/passwd", "x:\n", "nobody");
if (val == -1) { if (val == -1) {
perror("Failed locating user 'nobody'"); perror("Failed locating user 'nobody'");
return 1; return 1;
+33 -11
View File
@@ -4,6 +4,8 @@
#include <stdlib.h> #include <stdlib.h>
#include "check.h" #include "check.h"
#define BASEDIR "/tmp/libite-test"
int checkpath(const char *dir) int checkpath(const char *dir)
{ {
char tmp[256]; char tmp[256];
@@ -32,28 +34,48 @@ int test_makepath(const char *dir)
return ret; return ret;
} }
int test_fmkpath(const char *subdir)
{
int ret;
ret = fmkpath(0755, "%s/%s", BASEDIR, subdir);
if (!ret) {
char tmp[256];
snprintf(tmp, sizeof(tmp), "%s/%s", BASEDIR, subdir);
ret = checkpath(tmp);
} else
perror("Failed");
return ret;
}
int main(void) int main(void)
{ {
int i, ret = 0; int i, ret = 0;
char *list[] = { char *list[] = {
"/tmp/libite-test/tok/", BASEDIR "/tok/",
"/tmp/libite-test/tok2", BASEDIR "/tok2",
"/tmp/libite-test/ab", BASEDIR "/ab",
"/tmp/libite-test/b", BASEDIR "/b",
"/tmp/libite-test/a/", BASEDIR "/a/",
"/tmp/libite-test/a/b", BASEDIR "/a/b",
"/tmp/libite-test/a/c/", BASEDIR "/a/c/",
NULL NULL
}; };
printf("Testing makepath() ...\n"); mkdir(BASEDIR, 0755);
mkdir("/tmp/libite-test", 0755);
printf("Pass 1/2: makepath() =========================\n");
for (i = 0; list[i] && !ret; i++) for (i = 0; list[i] && !ret; i++)
ret |= test_makepath(list[i]); ret |= test_makepath(list[i]);
printf("\nCleaning up ...\n"); printf("Pass 2/2: fmkpath() ==========================\n");
system("rm -rf /tmp/libite-test"); for (i = 0; list[i] && !ret; i++)
ret |= test_fmkpath(list[i] + strlen(BASEDIR) + 1);
printf("Done: Cleaning up ============================\n");
system("rm -rf " BASEDIR);
return ret; return ret;
} }
+36
View File
@@ -0,0 +1,36 @@
#include <err.h>
#include "check.h"
int main(void)
{
struct { char *cmd; int rc; } list[] = {
{ "/app/enoent", 127 },
{ "false", 1 },
{ "true", 0 },
{ "kill -9 $$", -1 },
{ "kill -QUIT $$", -1 },
{ "kill -INT $$", -1 }
};
for (size_t i = 0; i < NELEMS(list); i++) {
int rc;
rc = systemf("%s", list[i].cmd);
if (rc != list[i].rc) {
if (rc == -1)
err(rc, "Failed %s", list[i].cmd);
else
errx(rc, "Failed %s, rc %d vs %d", list[i].cmd, rc, list[i].rc);
}
}
return 0;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+33 -2
View File
@@ -1,3 +1,4 @@
/* test of touch(), touchf(), erase(), and erasef() */
#include <err.h> #include <err.h>
#include <paths.h> #include <paths.h>
#include <signal.h> #include <signal.h>
@@ -6,6 +7,8 @@
#include "check.h" #include "check.h"
#define FMT "%s-bar"
int verbose = 0; int verbose = 0;
@@ -32,10 +35,38 @@ static int mtime(char *file)
ret = timespec_newer(&after.st_mtim, &before.st_mtim); ret = timespec_newer(&after.st_mtim, &before.st_mtim);
PRINT("Before: %s\n", timespec2str(&before.st_mtim, buf, sizeof(buf))); PRINT("Before: %s\n", timespec2str(&before.st_mtim, buf, sizeof(buf)));
PRINT("After : %s\n", timespec2str(&after.st_mtim, buf, sizeof(buf))); PRINT("After : %s\n", timespec2str(&after.st_mtim, buf, sizeof(buf)));
erase(file);
return !ret; return !ret;
} }
static int formatted(char *file)
{
char vrfy[80];
if (touchf(FMT, file))
err(1, "Failed creating " FMT, file);
PRINT("Created " FMT "\n", file);
snprintf(vrfy, sizeof(vrfy), FMT, file);
if (!fexist(vrfy))
errx(1, "touchf() does not detect failure to create file " FMT, file);
PRINT("File " FMT " really does exist!\n", file);
erasef(FMT, file);
if (fexist(vrfy)) {
int saved = errno;
erase(vrfy);
errno = saved;
errx(1, "erasef() failed removing the created file " FMT, file);
}
return 0;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int fd; int fd;
@@ -49,13 +80,13 @@ int main(int argc, char *argv[])
err(1, "Failed creating tempfile, %s", file); err(1, "Failed creating tempfile, %s", file);
close(fd); close(fd);
return mtime(file); return mtime(file) || formatted(file);
} }
/** /**
* Local Variables: * Local Variables:
* indent-tabs-mode: t * indent-tabs-mode: t
* c-file-style: "linux" * c-file-style: "linux"
* compile-command: "make pidfile && ./pidfile -v" * compile-command: "make touch && ./touch -v"
* End: * End:
*/ */
+7 -8
View File
@@ -11,17 +11,16 @@ int main(void)
int result = 0; int result = 0;
size_t i; size_t i;
struct tc test[] = { struct tc test[] = {
{ "ls", 1 }, { "executable", 1 },
{ "free", 1 }, { "executable -h", 1 },
{ "modinfo", 1 }, { "executable-link", 1 },
{ "useradd", 1 }, { "regular", 0 },
{ "/usr/bin/which", 1 }, { "ls", 1 },
{ "/bin/ps aux", 1 }, { "/usr/bin/which", 1 },
{ "/etc/passwd", 0 },
{ NULL, 0 } { NULL, 0 }
}; };
setenv("PATH", "/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin", 1); setenv("PATH", "data/which:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin", 1);
for (i = 0; test[i].cmd; i++) { for (i = 0; test[i].cmd; i++) {
char *path; char *path;