Commit Graph

179 Commits

Author SHA1 Message Date
Levi Neely b4f28ed681 Fix #103: Refactor putil to use putil_ namespace and enforce encapsulation
All public functions in putil now use the putil_ prefix (e.g., putil_strdup,
putil_strcat, putil_time_format, putil_base64_encode, etc.). Internal
variables (normalize_table, base64_reverse_table) and the constructor remain
static. Updated all 34 call-site files across pclsync accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 22:11:12 +01:00
Levi Neely d6858a0166
Fix #90, #109: Support 2FA when running as a daemon (#175)
* Fix #90: Support 2FA when running as a daemon

In daemon mode, when PSTATUS_TFA_REQUIRED fires:
- Automatically send an SMS 2FA code via psync_tfa_send_sms()
- Log delivery details to syslog with instructions to use
  `echo 'tfa CODE' | pcloudcc -k`
- Block on a condition variable until the code arrives via RPC

Add a new `tfa <code>` command to the pcloudcc -k control interface.
This sends the code to the daemon over the existing Unix socket RPC
channel (SENDTFA message type).

Bad codes (PSTATUS_BAD_TFA_CODE) are handled: the daemon logs a syslog
warning and waits for a corrected code without re-sending SMS.

Devices are trusted by default (trusted=1 in psync_tfa_set_code) so
repeated 2FA prompts are avoided for the configured trust period.
TFA codes are wiped from memory after use.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add auth command: supply password to running daemon

Mirrors the tfa command pattern. When PSTATUS_LOGIN_REQUIRED fires in
daemon mode, read_password() now logs a syslog notice and blocks on a
condition variable rather than calling exit(1).

The new `auth <password>` control command (SENDAUTH RPC type) signals
the condvar and unblocks the daemon. Usage:

  echo 'auth PASSWORD' | pcloudcc -k

The password is wiped from the CLI-side buffer immediately after the
RPC call. putil_wipe() is used for both the tfa and auth transient
strings on the sending side.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add status command: show current sync state from CLI

Adds a `status` (alias `st`) command to the interactive CLI and to the
pcloudcc -k control interface. The daemon-side handler calls
psync_get_status(), formats the status name plus download/upload
strings, and writes the result to shared memory. The client reads and
prints it.

Example output:
  Status:   READY
  Download: idle
  Upload:   idle

Also works non-interactively:
  echo 'status' | pcloudcc -k

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 21:36:33 +01:00
Levi Neely e3b9f7bfd8
Remove obsolete Pending Transfers section from README (#174)
* Fix #67: Add sync pause and sync resume commands

Wire psync_pause() and psync_resume() from the C library into the RPC
command layer, registering SYNCPAUSE and SYNCRESUME handlers and exposing
them as 'sync pause' and 'sync resume' CLI subcommands.

Note: daemon quit is already handled by the existing 'finalize' command,
which calls psync_destroy() and exits the daemon process cleanly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove obsolete Pending Transfers section from README

The pending command now provides a proper way to check for pending
transfers, making the manual cache-inspection workaround obsolete.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 20:17:10 +01:00
Levi Neely 79371d9aac
Fix #67: Add sync pause and sync resume commands (#173)
Wire psync_pause() and psync_resume() from the C library into the RPC
command layer, registering SYNCPAUSE and SYNCRESUME handlers and exposing
them as 'sync pause' and 'sync resume' CLI subcommands.

Note: daemon quit is already handled by the existing 'finalize' command,
which calls psync_destroy() and exits the daemon process cleanly.

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 20:12:53 +01:00
Levi Neely 0a697794dd
Add new pCloud SSL certificate fingerprint (#172)
Add SHA256 fingerprint 1b1b4d26a98774c84709c5400cd5c0b5e2f0bc7d46ef6053c9a872efe825b116 to fix OFFLINE status after pCloud SSL key rotation.

Fixes #171

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-03-01 09:14:29 +01:00
Levi Neely 4a870f8835
Add reference to pcloudcc-service (#170)
* Fix #162: Add distro-agnostic mbedtls detection

- Use pkg-config to dynamically detect mbedtls variants (mbedtls3.x, mbedtls)
- Fallback to /usr/local if pkg-config unavailable
- Tested on Fedora 41 (mbedtls3.6), Arch Linux (mbedtls 3.6.5), Debian Bookworm, and Slackware
- Eliminates need for hardcoded version-specific paths

* Add reference to pcloudcc-service

Closes #159

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-02-27 09:26:46 +01:00
Levi Neely 63d650b6c8
Fix #162: Add distro-agnostic mbedtls detection (#169)
- Use pkg-config to dynamically detect mbedtls variants (mbedtls3.x, mbedtls)
- Fallback to /usr/local if pkg-config unavailable
- Tested on Fedora 41 (mbedtls3.6), Arch Linux (mbedtls 3.6.5), Debian Bookworm, and Slackware
- Eliminates need for hardcoded version-specific paths

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-02-27 09:20:06 +01:00
Levi Neely 0900f742bb
Fix MBEDTLS-3.x.md: Add LIBLDFLAGS update to linker path (#168)
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-02-27 08:44:38 +01:00
Chris82111 29b45cf218
Retry opening without the O_NOATIME flag (#167)
Change looks good, much appreciated! :) Merged.
2026-02-27 08:40:38 +01:00
Jonathan Senkerik 441a0d69ed
Refactor logging, add cache-size, fs-event-log (#163)
Much appreciated! Merged. :)
2026-02-27 08:38:28 +01:00
Levi Neely b9ea6ca4c9 Remove unused psync_status_file/folder wrappers
- Both functions were pure aliases to psync_filesystem_status()
- Never called anywhere in the codebase
- Simplified API documentation to reference only psync_filesystem_status()
2026-02-14 20:08:01 +01:00
Levi Neely 2c5e32e910 Fix #95: Remove unused get_token() wrapper from pclsync_lib
- Eliminates thin wrapper that just called psync_get_token()
- Function was declared but never used
- Simplifies pclsync_lib API as per issue #95
2026-02-14 20:08:01 +01:00
Levi Neely 11074655db Fix #8: Add pending transfer check feature
- Add new 'pending' command (alias 'p') to check for pending transfers
- Enhance 'finalize' command to warn about pending transfers
- Prompt for confirmation in interactive mode before shutdown
- Use psync_get_status() API for reliable transfer detection
- Shows upload/download counts separately
- Fix mbedtls 3.6 compatibility issues in pssl.c
- Update Makefile for mbedtls 3.x static linking
2026-02-14 19:43:13 +01:00
Levi Neely e566c7822a Fix #107: Add SMS 2FA support
- Enhance read_tfa_code() to offer SMS option
- User can type 'sms' to receive code via SMS
- Display phone number when SMS is sent
- Falls back to authenticator app if SMS fails
- Uses existing psync_tfa_send_sms() API
2026-02-14 19:20:10 +01:00
Levi 0a14098935 arm64 arch devhost 2025-07-20 16:01:47 +02:00
Levi Neely a11575b9da
fix compile errors (#155) 2025-05-15 19:14:57 +02:00
ahuemmer 95cbf63a57
fix: add stdlib to fix build (#153) 2025-04-20 22:41:33 +02:00
Levi Neely 6540e14732
move folder-related code from psynclib to pfolder 2025-04-18 15:23:50 +02:00
Levi Neely 1dd703142d
Merge branch 'nix-shell' [#151] 2025-04-18 13:29:37 +02:00
Levi Neely 2df5ef876f
add watchexec to dev shell 2025-04-18 11:32:16 +02:00
kost a4b92682ba
Musl fixes (#143)
* use libunwind where glibc is not available

* use sys/stat.h for struct stat definition
2025-04-13 09:11:11 +02:00
Levi Neely 9842c90f89
direnv (#150)
* enable direnv for dev shell
2025-04-13 08:53:41 +02:00
Levi Neely 376fbfffc9
Merge branch 'main' into nix-shell 2025-04-13 08:52:37 +02:00
Levi Neely 0ce5713f0f enable direnv for dev shell 2025-04-13 08:47:23 +02:00
Levi Neely 3dfb8de927
Nix shell uses flakes (#147)
* nix shell now uses flakes
2025-04-11 20:55:58 +02:00
Levi Neely 1ae036c032 nix shell now uses flakes 2025-04-11 20:54:28 +02:00
Levi Neely 1938924218 Merge branch 'main' into nix-shell 2025-04-11 20:54:08 +02:00
Levi Neely 1e2d16cb7f
nix dev shell (#146) 2025-04-11 00:44:35 +02:00
Levi Neely 87bbab2d06 nix dev shell 2025-04-11 00:41:26 +02:00
Levi Neely cf818e539e
Update README.md (#145) 2025-04-08 14:45:08 +02:00
Levi Neely 9087e5d3ac
update devscripts, new arch devhost (#144) 2025-04-06 23:01:31 +02:00
V10lator bd576e3c5b
Allow custom flags (#141)
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
2025-03-18 19:55:15 +01:00
Levi Neely 6994a3cac9
102 create a psql namespace (#142)
* another stupid macro gone

* more stupid macros gone. moved util functions from plibs to putil

* remaining plist and ptask functions moved to appropriate namespaces

* dead code beleted!

* bugfixes

* move sql functions to psql.c

* move sort functions into ppagecache

* psql namespace

* change plibs.h include to pdbg.h

* cleanup includes
2025-03-18 19:52:15 +01:00
Levi Neely 58461232db
fix weird name (#140) 2025-03-13 20:44:42 +01:00
Levi Neely 9014edb99a
98 create a pdbg namespace (#139)
* pdbg split from plibs
* pdbg namespace
* add SSLDBGLVL build option
2025-03-13 20:28:09 +01:00
Levi Neely 9da561c767
131 remove custom memory management wrappers (#137)
* psync_free removed

* psync_malloc removed

* psync_realloc removed

* remove dead code

* remove pmemlock

* remove dead code
2025-03-11 22:27:30 +01:00
Levi Neely 3fd249f3f8
manual formatting (#136) 2025-03-11 21:36:26 +01:00
Levi Neely 3e177864ec
use process_command in process_commands (#135) 2025-03-11 20:49:22 +01:00
Levi Neely ce6033fe95
130 use trustworthy location for log and socket (#134)
* trustworthy location for log and socket
- socket in => $HOME/.pcloud/prpc.sock (mode 0600)
- debug log => $HOME/.pcloud/debug.log
* documentation updates
2025-03-11 19:03:58 +01:00
Levi Neely 79141898c3
84 security enhancements (#133)
- DoD 5220.22-M compliant memory wipe replaces single-pass zero wipe
- Wipe in-memory request and response messages before freeing
- Wipe in-memory private keys and salt data before freeing
- Wipe all passwords on unlink / logout
- Wipe crypto password on all pcryptofolder_unlock return paths
2025-03-11 15:05:43 +01:00
Levi Neely 3c713d6437
remove version check and download code (#127) 2025-03-09 20:36:25 +01:00
Levi Neely 28b985649f
rpcclient is now part of the CLI program (#126) 2025-03-09 20:20:33 +01:00
Levi Neely d3bea1c641
access pcryptofolder directly from pclsync_lib (#125)
* access pcryptofolder directly from pclsync_lib
* move issetup to pcryptofolder
2025-03-09 19:58:00 +01:00
Levi Neely 43521f603c
resolve cmd ambiguity, just support pipe input (#124) 2025-03-09 19:25:34 +01:00
Levi Neely 27977765e8
non interactive command processing (#123)
* support non-interactive command processing
- app is now configured in setup_app function
- added process_command() to api
- support piped input and -c argument
- fix memleaks
2025-03-09 19:18:38 +01:00
Levi Neely f437fe840e
prpc namespace and api cleanup (#122)
* prpc namespace and api cleanup
2025-03-09 17:13:35 +01:00
Levi Neely 8db64e8a4a
pssl namespace decomposition, remove compat junk (#121) 2025-03-09 16:39:30 +01:00
Levi Neely f266351e55
Update README.md (#119) 2025-03-09 15:34:16 +01:00
Levi Neely 826c2e3edf
upgrade to mbedtls 3.x (#118)
Migrate mbedtls 2.x to mbedtls 3.x.
2025-03-09 15:16:46 +01:00
Levi Neely eb04ac246a
Fix deprecated function and write() warnings (#117)
* add readline to dev containers

* pssl function names

* fix deprecated function warnings

* fix more deprecated function warnings

* fix warnings on write()
2025-03-09 09:45:45 +01:00