Skip to content

Commit

Permalink
Sign exchange with sig, and add sig_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonsingh committed Sep 19, 2024
1 parent efacc7f commit d7b880e
Show file tree
Hide file tree
Showing 5 changed files with 412 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
mkdir sig
curl -s "$(curl -s https://api.github.com/repos/claytonsingh/tools/releases/latest | jq -r '.assets[] | select(.name == "sig.tar.gz") | .browser_download_url')" -L -o- | tar -xzv -C sig
- name: Build
run: |
mkdir bin
gcc exchange.c -s -Os -o exchange
- name: Package
run: |
tar -czv -O -C bin . > exchange.tar.gz
echo "${SIG_KEY}" | sig/sig-linux-x64 sign --if exchange.tar.gz /dev/stdin --of exchange.tar.sig.gz
- name: Upload Release
run: |
gh release upload "${GITHUB_REF_NAME}" exchange.tar.gz
gh release upload "${GITHUB_REF_NAME}" exchange.tar.gz exchange.tar.sig.gz
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
build-sig:
Expand Down
57 changes: 57 additions & 0 deletions exchange/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# exchange

A simple C program to atomically exchange two files or folders using the `renameat2(2)` system call.

## Description

This program provides a command-line interface to the `renameat2` system call with the `RENAME_EXCHANGE` flag, allowing users to atomically swap the names of two files or directories.

## Notes

- This program requires a Linux kernel that supports the `renameat2` system call (Linux 3.15 and later).
- The program uses direct system calls, which may not be portable across all Linux distributions or kernel versions.

## Building

To compile the program, use:
```bash
gcc exchange.c -s -Os -o exchange
cp exchange /usr/local/bin/exchange
```

## Usage
To exchange two files or directories, run:
```
./exchange file1.txt file2.txt
./exchange dir1 dir2
```

## Contributing

Contributions are welcome! Open a pull request.

## License

```
MIT License
Copyright (c) 2024 Clayton Singh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
3 changes: 3 additions & 0 deletions github_public.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAzl8VeJlM51SWa9wlOHRRvpdK0ZN1EPNMrQmLrZ9p6dk=
-----END PUBLIC KEY-----
39 changes: 39 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Monorepo Tools Collection

This monorepo contains various command-line tools and utilities for different purposes.

## Tools Included

- **exchange** - Atomically swap two files or directories.
- **sig** - For signing, fetching, verifying, and inspecting signed documents.

## Getting Started

1. Clone the repository:
```bash
git clone https://github.com/claytonsingh/tools.git
```

2. Navigate to the specific tool directory:
```bash
cd tools/tool-name
```

3. Follow the individual README instructions for each tool.

## Releases

Releases for all tools are grouped together. To find the latest releases:

1. Visit the [Releases page](https://github.com/claytonsingh/tools/releases) of this repository.
2. Each release contains updates for all tools in the monorepo.
3. Release notes will specify which tools have been updated and their respective version numbers.
4. Download the release package, which includes pre-built binaries for all tools and supported platforms.

## Contributing

Contributions are welcome! Open a pull request.

## License

Each tool is licensed under its own license.
Loading

0 comments on commit d7b880e

Please sign in to comment.