Skip to content

Commit

Permalink
Cleanup, updated license and dependencies (#4)
Browse files Browse the repository at this point in the history
* License, cleanup, updated dependencies

* Added CI build for Linux and FreeBSD, both for arm and amd64

* Fix for insecure strncpy

* Increased version number
  • Loading branch information
nozomi-slibero authored Nov 28, 2023
1 parent 480ef8f commit 83e9d2a
Show file tree
Hide file tree
Showing 25 changed files with 527 additions and 339 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Multi-platform build

on:
push:
branches: master
tags: "*"
workflow_dispatch:
pull_request:

jobs:
build-linux:
uses: ./.github/workflows/linux.yml
secrets: inherit
build-freebsd:
uses: ./.github/workflows/freebsd.yml
secrets: inherit
finalize:
runs-on: ubuntu-22.04
needs: [build-linux, build-freebsd]
steps:
- name: Download artifact - FreeBSD x86-64
uses: actions/download-artifact@v3
with:
name: n2os_smb_client.bsd_x86-64
path: bin/
- name: Download artifact - FreeBSD arm64
uses: actions/download-artifact@v3
with:
name: n2os_smb_client.bsd_arm64
path: bin/
- name: Download artifact - Linux x86-64
uses: actions/download-artifact@v3
with:
name: n2os_smb_client.linux_x86-64
path: bin/
- name: Download artifact - Linux arm64
uses: actions/download-artifact@v3
with:
name: n2os_smb_client.linux_arm64
path: bin/
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
with:
files: |
bin/n2os_smb_client.bsd
bin/n2os_smb_client.bsd_arm64
bin/n2os_smb_client.linux
bin/n2os_smb_client.linux_arm64
fail_on_unmatched_files: true
generate_release_notes: true
34 changes: 34 additions & 0 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: FreeBSD build

on:
workflow_dispatch:
workflow_call:

jobs:
freebsdbuild:
timeout-minutes: 30
runs-on: ubuntu-22.04
name: Build on FreeBSD
strategy:
matrix:
arch: [x86-64, arm64]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cross Platform Action
uses: cross-platform-actions/action@v0.21.1
with:
operating_system: freebsd
version: "13.2"
shell: bash
sync_files: true
architecture: ${{ matrix.arch }}
run: |
sudo pkg install -y cmake
./build.bsd.sh
- name: Store executable
uses: actions/upload-artifact@v3
with:
name: "n2os_smb_client.bsd_${{ matrix.arch }}"
path: bin/n2os_smb_client.bsd*
56 changes: 56 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Linux build

on:
workflow_dispatch:
workflow_call:

env:
IMG_TAG: smblinux-builder:latest

jobs:
linuxsetup:
timeout-minutes: 30
runs-on: ubuntu-22.04
name: Build on Linux
strategy:
matrix:
arch:
- name: x86-64
platform: linux/amd64
bin_name: n2os_smb_client.linux
artifact: n2os_smb_client.linux_x86-64
env_arm: ""
- name: arm64
platform: linux/arm64
bin_name: n2os_smb_client.linux_arm64
artifact: n2os_smb_client.linux_arm64
env_arm: "1"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ matrix.arch.platform }}
- name: Build and export to Docker
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.arch.platform }}
file: ./Dockerfile.linux
target: builder
load: true
push: false
tags: ${{ env.IMG_TAG }}
build-args: ENV_ARM=${{ matrix.arch.env_arm }}
- name: Fetch executable from the container
run: |
docker run --platform ${{ matrix.arch.platform }} --rm --volume "${PWD}/bin:/artifacts" ${{ env.IMG_TAG }} cp /usr/src/n2os-smb-client/bin/${{ matrix.arch.bin_name }} /artifacts
- name: Store executable
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.arch.artifact }}
path: bin/${{ matrix.arch.bin_name }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
cmake-build*
cmake-build*
bin/
.vscode
build/
.cache/
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

22 changes: 0 additions & 22 deletions .idea/deployment.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/n2os-smb-client.iml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/other.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/vcs.xml

This file was deleted.

59 changes: 59 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"code-block-style": {
"style": "fenced"
},
"code-fence-style": {
"style": "backtick"
},
"emphasis-style": {
"style": "asterisk"
},
"fenced-code-language": {
"allowed_languages": [
"bash",
"html",
"javascript",
"json",
"markdown",
"text"
],
"language_only": true
},
"heading-style": {
"style": "atx"
},
"hr-style": {
"style": "---"
},
"line-length": {
"strict": false,
"code_blocks": false
},
"no-duplicate-heading": {
"siblings_only": true
},
"ol-prefix": {
"style": "ordered"
},
"proper-names": {
"code_blocks": false,
"names": [
"Cake.Markdownlint",
"CommonMark",
"JavaScript",
"Markdown",
"markdown-it",
"markdownlint",
"Node.js"
]
},
"reference-links-images": {
"shortcut_syntax": true
},
"strong-style": {
"style": "asterisk"
},
"ul-style": {
"style": "dash"
}
}
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(LIBSMB2_DIR "${PROJECT_SOURCE_DIR}/deps/libsmb2")
message(STATUS "Lib smb2: ${LIBSMB2_DIR}")

if (NOT "${CMAKE_SYSTEM}" MATCHES "Linux")
# freebsd specific fixes
# FreeBSD specific fixes
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_definitions(-include freebsd_fix.h)
add_compile_options("-Wno-macro-redefined")
Expand Down Expand Up @@ -69,7 +69,9 @@ include_directories(${LIBJSONC_DIR})
include_directories(${LIBSMB2_DIR}/include/smb2)
include_directories(${LIBSMB2_DIR}/include)


if (${BUILD_WITH_KRB5})
link_libraries(${GSSAPI_LIBRARY} ${KRB_LIBRARY} smb2 json-c)
endif()
add_executable(n2os_smb_client n2os-smb-client.c)

if (${BUILD_WITH_KRB5})
Expand Down
16 changes: 16 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
n2os-smb-client is released under the BSD 2-Clause License license.

Included 3rd party software
===========================
This software includes libsmb2 and json-c, with their original repositories linked
as github modules.

libsmb2 is released under LGPL 2.1 (or later) for what concerns lib and include directories,
and the 2-Clause BSD License for its examples directory.
Copyright (C) 2016 by Ronnie Sahlberg <ronniesahlberg@gmail.com>

json-c is release under the MIT license.
Copyright (c) 2009-2012 Eric Haszlakiewicz
Copyright (c) 2004, 2005 Metaparadigm Pte Ltd

See their respective subdirectories for detailed license information.
47 changes: 47 additions & 0 deletions Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Dockerfile for Linux
#
# Build:
# docker build -t "smblinux:latest" -f Dockerfile.linux .
#
# Build with Kerberos support:
# docker build --progress plain -t "smblinux:latest" --build-arg WITH_KERBEROS=1 -f Dockerfile.linux .
#
# Run with no options:
# docker run --rm smblinux:latest
#
# Run a n2os-smb-client command directly:
# docker run --env N2OS_SMB_PASSWORD=${N2OS_SMB_PASSWORD} --rm -v "$PWD/bin":/usr/src/n2os-smb-client/bin:Z smblinux:latest ls smb://media@192.168.1.100/_media
#
# Interactive shell on the container image:
# docker run -ti --entrypoint /bin/bash smblinux:latest

# FROM debian:bookworm-slim # no upx at the moment
FROM debian:bullseye-slim AS builder

ARG WITH_KERBEROS
ENV WITH_KERBEROS=${WITH_KERBEROS}

# Used in GHA workflow
ARG ENV_ARM
ENV ENV_ARM=${ENV_ARM}

WORKDIR /usr/src/n2os-smb-client
COPY . .

# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends git build-essential upx-ucl cmake libssl-dev libkrb5-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
ldconfig && \
./build.linux.sh

FROM debian:bullseye-slim

RUN useradd -m nonroot

COPY --from=builder /usr/src/n2os-smb-client/bin/n2os_smb_client.linux /usr/bin/n2os_smb_client.linux

USER nonroot
WORKDIR /home/nonroot

ENTRYPOINT [ "/usr/bin/n2os_smb_client.linux" ]
Loading

0 comments on commit 83e9d2a

Please sign in to comment.