Git Product home page Git Product logo

Comments (10)

bailey27 avatar bailey27 commented on September 25, 2024

@LORDofDOOM ,

Thanks for reporting these issues.

I will add command line options and look into the time/date issue with rsync.

from cppcryptfs.

bailey27 avatar bailey27 commented on September 25, 2024

@LORDofDOOM ,

I've added command line options. Please see the README.md for usage.

I did a quick test with rsync, and I don't see the problem.

I mounted a filesystem on k: and then did

rsync -avP . /cygdrive/k/foo/ 

And the file times/dates were preserved (the files were from August).

from cppcryptfs.

LORDofDOOM avatar LORDofDOOM commented on September 25, 2024

Thank you very much for the commandline update. For the date/time - That was my fault - The problem is amazon cloud drive not cppcryptfs - It seems that Amazon can't handle date/time correct. Sry for this.

The --tray and --exit options are really useful too - THX 👍

from cppcryptfs.

LORDofDOOM avatar LORDofDOOM commented on September 25, 2024

A little issue with the commandline options:

the commandline/cppcryptfs blocks if used in batch/script

Sample:

cppcryptfs --unmount=u --tray --exit
cppcryptfs.exe --mount=d:\TestCryptCppFS --drive=u --password=PASSWORD --tray  --exit
robocopy  C:\test.txt U:\test.txt

if I use this sample as batch file the second line (cppcryptfs.exe --mount) blocks until cppcryptfs exits. This prevent use of batch files or multiple mounting in scripts.

Sample for a backup batch thats breaks on line 3 (first call of cppcryptfs.exe --mount):

cppcryptfs --unmount=u --tray --exit
cppcryptfs --unmount=v --tray --exit
cppcryptfs.exe --mount=d:\TestCryptCppFS --drive=u --password=PASSWORD --tray  --exit
cppcryptfs.exe --mount=d:\TestCryptCppFS2 --drive=v --password=PASSWORD --tray  --exit
robocopy  C:\test.txt U:\test.txt
robocopy  C:\test.txt V:\test.txt
cppcryptfs --unmount=u --tray --exit
cppcryptfs --unmount=v --tray --exit

from cppcryptfs.

bailey27 avatar bailey27 commented on September 25, 2024

@LORDofDOOM ,

The way an instance of cppcryptfs deals with command line options is like this:

If there is no instance of cppcryptfs already running, then it processes the command line options itself.

If there is another instance already running, then the second instance of cppcryptfs sends the command line to the first instance and blocks until the first instance is done processing the command line options (e.g. the mount operation completes). The first instance will redirect its stderr and stdout to the console of the second instance, so you can see any error messages it prints.

If you run cppcryptfs or most other windows gui apps (e.g. notepad) from cygwin bash, they will block until exit unless you run them in the background with &

I worked around the blocking problem in the bash example in the readme by starting an instance of cppcryptfs in the background before doing anything else.

#!/bin/bash
# start cppcryptfs in the background and hidden in the system tray
/cygdrive/c/bin/cppcryptfs -t &
# give it time to initialize
sleep 1
# mount a filesystem and wait for the mount operation to complete
/cygdrive/c/bin/cppcryptfs --mount c:\\tmp\\test -d k -p XYZ
# do backup operation
rsync .....
# unmount all drives and exit
./cppcryptfs -u all -x

The second instance of cppcryptfs will tell the background instance to do the mount, and it will exit when the mount operation is completed so the script can continue.

Would this technique work in your case?

from cppcryptfs.

LORDofDOOM avatar LORDofDOOM commented on September 25, 2024

Thank you for your quick answer

The way you describe seems correct - Blocking until the command is processed make sense - But cppcryptfs should release lock if the commandline parameter is done (e.g. if the drive is mounted/unmounted it should release lock and accept next command and free the console). The same way e.g. TrueCrypt/VeraCrypt works.

The problem with lock is that's not possible to mount multiple drives in one script/batch (see my second example).

It should be possible to open a cmd.exe or bash and open cppcryptfs from there without exit the main process to make it possible to run in a init script or in windows task schedule (batch)

I want to add a batch to windows autostart like this:

@echo ====================================================
@echo Dismount mounted drives - ignore errors
@echo ====================================================

cppcryptfs --unmount=u --tray --exit
cppcryptfs --unmount=v --tray --exit

@echo ====================================================
@echo Mount drive U:
@echo ====================================================

cppcryptfs.exe --mount=d:\TestCryptCppFS --drive=u --password=PASSWORD --tray  --exit

@echo ====================================================
@echo Mount drive V:
@echo This will not work until first instance in closed 
@echo ====================================================

cppcryptfs.exe --mount=d:\TestCryptCppFS2 --drive=v --password=PASSWORD --tray  --exit

@echo ====================================================
@echo Run any command with the mounted drives
@echo ====================================================

robocopy  C:\test.txt U:\test.txt
robocopy  C:\test.txt V:\test.txt

from cppcryptfs.

bailey27 avatar bailey27 commented on September 25, 2024

@LORDofDOOM ,

I found out something I never noticed before.

If you start a windows gui app in a command shell, it doesn't block. But if you start it in a batch file, it does block.

I got your backup script to work.

I started a cppcryptfs instance in the background with "start" and run the others (that talk to it) with "start /wait" . It seems to work.

The robocopy commands didn't work. I think it wants to copy only directories. So I changed them to plain copies.

@echo ====================================================
@echo Dismount mounted drives - ignore errors
@echo ====================================================

start /wait cppcryptfs --unmount=u --tray --exit
start /wait cppcryptfs --unmount=v --tray --exit

@echo ====================================================
@echo run cppcryptfs in background and give it time to startup
@echo ====================================================

start cppcryptfs.exe --tray
timeout /t 1 >nul

@echo ====================================================
@echo Mount drive U:
@echo ====================================================

start /wait cppcryptfs.exe --mount=d:\TestCryptCppFS --drive=u --password=PASSWORD --tray  --exit

@echo ====================================================
@echo Mount drive V:
@echo Should work now
@echo ====================================================

start /wait cppcryptfs.exe --mount=d:\TestCryptCppFS2 --drive=v --password=PASSWORD --tray  --exit

@echo ====================================================
@echo Run any command with the mounted drives
@echo ====================================================

copy  C:\test.txt U:\test.txt
copy  C:\test.txt V:\test.txt

Is this ok?

from cppcryptfs.

LORDofDOOM avatar LORDofDOOM commented on September 25, 2024

This method works partially - It will mount multiple drives and copy the files - But the commandline window don't close after the batch is done... If I use this command on windows autostart the drives get mounted and the copy command will successfully complete but commandline dont disappear until i close cppcryptfs.

It's possible to wrap this into a shell execute and start a hidden commandline but I think many users will get mount their drives on autostart and a batch file is the most easy method to get this done. If shell execute is used the user need to script something in C#/Python/VBScript...

from cppcryptfs.

bailey27 avatar bailey27 commented on September 25, 2024

@LORDofDOOM ,

I think I found the problem.

It looks like the cmd window was hanging around because cppcryptfs (the one that keeps running in the background) was holding open the stderr and stdout from the invoking cmd window.

I made it close stderr and stdout and then free the console after processing the command line.

Before processing the command line options, it attaches to the console and reopens stderr and stdout from that console. So the error messages keep working. But now it closes everything after finishing the command line options processing.

Now when I run the above batch file from a shortcut on the desktop, the window closes automatically when it finishes. It wasn't closing before, like you said.

Please try it and let me know if it solves the problem.

from cppcryptfs.

LORDofDOOM avatar LORDofDOOM commented on September 25, 2024

Great: With this change I'm able to run cppcryptfs in batchfiles, autostart and shellscripts- Commandline window will close after successfully run :-)

@echo ====================================================
@echo Dismount mounted drives - ignore errors
@echo ====================================================

cppcryptfs --unmount=u --tray --exit
cppcryptfs --unmount=v --tray --exit

@echo ====================================================
@echo run cppcryptfs in background and give it time to startup
@echo ====================================================

start cppcryptfs.exe --tray
timeout /t 1 >nul

@echo ====================================================
@echo Mount drive U:
@echo ====================================================

cppcryptfs.exe --mount=d:\TestCryptCppFS --drive=u --password=PASSWORD --tray  --exit

@echo ====================================================
@echo Mount drive V:
@echo ====================================================

cppcryptfs.exe --mount=d:\TestCryptCppFS2 --drive=v --password=PASSWORD --tray  --exit

@echo ====================================================
@echo Run any command with the mounted drives
@echo ====================================================

copy  C:\test.txt U:\test.txt
copy  C:\test.txt V:\test.txt

Thank you

from cppcryptfs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.