- Use sig_atomic_t flag instead of calling unsafe functions in signal handlers
- Remove pdbg_logf() and exit() calls from psync_signal_handler
- Check shutdown_requested flag in main loops
- Export flag for cross-module access
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
- Wrap std::stoull() in try/catch to prevent daemon crash on invalid folder ID
- Add proper read loop for RPC messages to handle partial reads
- Validate msg->length before memcpy to prevent heap over-read
- Handle daemon bugs gracefully (EOF before full message)
- Fix operator precedence in sync remove command
Fixes#205, #206
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
* Fix debug build segfault: add strong overrides for psql_lock/unlock functions
The weak/strong symbol approach requires that psql.c undefs the debug
macros to define function implementations. This means functions in psql.c
call psql_lock()/psql_unlock() as functions, not macros.
In debug builds, these must be strong overrides that call the _do_
variants to properly maintain lockctr/rdlockctr. Without these overrides,
the weak stubs are used which don't update counters, causing assertion
failures in psql_unlock().
Added strong overrides in psql_debug.c for:
- psql_lock() -> psql_do_lock(__FILE__, __LINE__)
- psql_rdlock() -> psql_do_rdlock(__FILE__, __LINE__)
- psql_statement() (calls psql_do_lock directly)
Also made psql_statement, psql_start, and all query/prepare functions
weak in psql.c to allow debug overrides.
Fixes#138
* Fix umask and password memory wipe
- Set umask(0077) in daemonize() to prevent world-readable files
- Wipe password from memory after psync_set_user_pass()
Fixes#203, #204
---------
Co-authored-by: Levi Neely <lkn@darkstar.example.net>
* 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>
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>
- 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
* 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
* pcommands.h for command ids
* remove compiler compat junk
* transient and unnecessary includes resolved
* unnecessary goto
* function naming and whatnot
* use readline for better command line UX
* add readline to CI workflow
* small lsp error fixes
* simplify messaging and remove serialize/deserialize
- messaging is reverted to API requests and responses only
- remove serialize and deserialize functions
- implement shared memory (pshm) for overlay callback return values
* fix memory leak
Fix#64 and #71
Problem was that the way the add sync folder command was handling local and remote path was based on the previous CLI processor, i.e., one string for all args. This patch updates it for CLI11.hpp
* list_sync_folders seems to work
* list_sync_folders breaks with sync folders in db; message size problem?
* fixed sync folders list
* fix double free and buffer overflow
* wip: add and remove sync folder; need to fix request->value in instance_thread
* remove comment
* removed pclsync_lib_c.{h,cpp}
* cleanup get_answer_to_request
* update comment
* changed reply struct to type response containing payload and msg
* cleanup
* refactored overlay_client, and poverlay; added docs
* better naming
* sock path in poverlay_protocol.h
* clarify comment
* refactor psync_overlay_get_response
* clarifications
* response_messages work with and without payload
* removed commented code
* syncadd works, but i need to fix the error handling
* remove sync folder
* remove commented code, change printfs to debug or simply remove
* removed unnecessary print
* removed more prints
* removed dead var
* update error handling in add_sync_folder, fix memleak
* simplified finalize
* reorg source tree, link system mbedtls
* remove cmakelists.txt
* update ci workflow
* -Werror to -Wall
* libpcloudcc_so in makefile
* single makefile works
* removed extra makefiles