Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
llbrt committed Apr 8, 2021
1 parent 672054a commit 3b6b0a1
Show file tree
Hide file tree
Showing 74 changed files with 1,141 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# maven
target
dependency-reduced-pom.xml

# IDE
.idea
.settings
.project
.classpath

# MacOS
.DS_Store

# Other
.factorypath
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Command line interface to access to a vault encrypted with [Cryptomator](https://github.com/cryptomator/cryptomator)

If you find this project useful, consider donating to [CRYPTOMATOR](https://cryptomator.org/donate/)

## Features

- Access Cryptomator encrypted vaults opened with a Java command line on a platform compatible with [FUSE](https://en.wikipedia.org/wiki/Filesystem_in_Userspace)
- Create a Debian package containing the application and a minimum JRE

## Build

This project requires [Maven](https://maven.apache.org/) and a JDK version 11.

For a smaller package, the build should be done with the community version of Azul, [Zulu](https://www.azul.com/downloads/zulu-community/?version=java-11-lts&os=linux&package=jdk) (around deb 27MB / installed 47MB with Zulu11.39+15-CA (build 11.0.7+10-LTS), but deb 87MB/ installed 322MB with 11.0.8+10-post-Ubuntu-0ubuntu118.04.1).

The command `dpkg-deb` is necessary to create the Debian package.

## Usage

The command `/opt/cryfsmount/bin/cryfsmount` can create a new vault or migrate an old vault to the latest format.

Close the vault be stopping the process.

If the mount point is not set, a new temporary directory is created.

The passphrase of the vault can be typed, set in a file or in an environment variable.

*WARNING*: when the passphrase is set in a file, make sure there is no trailer end-of-line. For the string `My pass`, create the file with
```
echo -n "My pass" > pass.txt
```

*WARNING*: the command `cryfsumount` stops ALL the running `cryfsmount` processes.
267 changes: 267 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.github.llbrt.cryptofssrv</groupId>
<artifactId>cryfsmount</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<scm>
<connection>scm:git:[email protected]:llbrt/cryfsmount.git</connection>
<developerConnection>scm:git:[email protected]:llbrt/cryfsmount.git</developerConnection>
<url>https://github.com/llbrt/cryfsmount</url>
</scm>

<licenses>
<license>
<name>GNU Affero General Public License (AGPL) version 3.0</name>
<url>https://www.gnu.org/licenses/agpl.txt</url>
<distribution>manual</distribution>
</license>
</licenses>

<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

<cmd.mount>cryfsmount</cmd.mount>
<cmd.umount>cryfsumount</cmd.umount>

<!-- Dependencies -->
<cryptomator-fuse.version>1.2.4</cryptomator-fuse.version>
<cryptomator-fs.version>1.9.12</cryptomator-fs.version>
<picocli.version>4.5.1</picocli.version>
<logback.version>1.2.3</logback.version>
<junit.version>5.7.0</junit.version>
</properties>

<dependencies>
<!-- Cryptomator -->
<dependency>
<groupId>org.cryptomator</groupId>
<artifactId>fuse-nio-adapter</artifactId>
<version>${cryptomator-fuse.version}</version>
</dependency>
<dependency>
<groupId>org.cryptomator</groupId>
<artifactId>cryptofs</artifactId>
<version>${cryptomator-fs.version}</version>
</dependency>

<!-- Logs -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>

<!-- CLI -->
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>

<!-- Tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<targetPath>${project.build.outputDirectory}</targetPath>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/packaging/skel</directory>
<targetPath>${project.build.directory}/packaging/opt/${cmd.mount}</targetPath>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/packaging/deb</directory>
<targetPath>${project.build.directory}/packaging/</targetPath>
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>${java.version}</release>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<escapeString>\</escapeString>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.github.llbrt.cryptofs.CryFsMount</mainClass>
</transformer>
</transformers>
<outputFile>${project.build.directory}/packaging/opt/${cmd.mount}/app/${cmd.mount}.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<target>
<move file="${project.build.directory}/packaging/opt/${cmd.mount}/bin/mount.sh" tofile="${project.build.directory}/packaging/opt/${cmd.mount}/bin/${cmd.mount}" />
<move file="${project.build.directory}/packaging/opt/${cmd.mount}/bin/umount.sh" tofile="${project.build.directory}/packaging/opt/${cmd.mount}/bin/${cmd.umount}" />
</target>
</configuration>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>package-jre</id>
<goals>
<goal>exec</goal>
</goals>
<phase>package</phase>
<configuration>
<!-- Creates the jre directory -->
<executable>jlink</executable>
<arguments>
<argument>--no-header-files</argument>
<argument>--no-man-pages</argument>
<argument>--compress=2</argument>
<argument>--strip-debug</argument>
<argument>--add-modules</argument>
<!-- Check the list of modules, especially when modifying dependencies -->
<!-- jdk.jcmd is necessary to get the command jps -->
<argument>java.base,java.compiler,java.logging,java.management,java.naming,java.sql,java.xml,jdk.unsupported,jdk.jcmd</argument>
<argument>--output</argument>
<argument>${project.build.directory}/packaging/opt/${cmd.mount}/jre</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>create-deb-package</id>
<goals>
<goal>exec</goal>
</goals>
<phase>package</phase>
<configuration>
<!-- Create the Debian package -->
<executable>dpkg-deb</executable>
<arguments>
<argument>--root-owner-group</argument>
<argument>--build</argument>
<argument>${project.build.directory}/packaging</argument>
<argument>${project.build.directory}/${cmd.mount}_${project.version}_amd64.deb</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>${java.version}</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-property-updates</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.8.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
47 changes: 47 additions & 0 deletions src/main/java/com/github/llbrt/cryptofs/CryFsMount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.github.llbrt.cryptofs;

import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import picocli.CommandLine;

public final class CryFsMount {

private static final Logger logger = LoggerFactory.getLogger(CryFsMount.class);

public static void main(String[] args) {
CommandLine cmd = new CommandLine(new Mount());
int exitCode = cmd.execute(args);
if (exitCode != 0) {
System.exit(exitCode);
}
MountedFs mountedFs = cmd.getExecutionResult();
String message = mountedFs + " mounted on " + mountedFs.getMountPoint();
logger.info(message);
System.out.println(message);

// Prepare umount
Runtime.getRuntime().addShutdownHook(new Thread(() -> mountedFs.umount(), "Umounter"));

// Wait for kill in a separate thread
new Thread(() -> {
while (true) {
try {
TimeUnit.MINUTES.sleep(4);
} catch (InterruptedException e) {
// ignored
}
}
}, "Keep alive thread").start();

try {
System.in.close();
} catch (Exception e) {
logger.warn("Failed to close input stream", e);
}
System.out.close();
System.err.close();
}
}
Loading

0 comments on commit 3b6b0a1

Please sign in to comment.