Commit Graph

230 Commits (master)

Author SHA1 Message Date
Michael Santos 0ba12c23af seccomp: allow ppoll(), faccessat() 4 years ago
Michael Santos f80ab9c65e Update README/usage 4 years ago
Michael Santos 91a43f2433 -V/--version: display version information 4 years ago
Michael Santos 69391951c8 freebsd: fix capsicum warning
~~~
In file included from src/restrict_process_capsicum.c:16:                   /usr/include/sys/capability.h:44:2: warning: this file includes <sys/capability.h> which is deprecated [-W#warnings]
 ^
1 warning generated.
~~~
4 years ago
Michael Santos 4997f4be2c 0.14.0 4 years ago
Michael Santos 45e96e6ea9 s/XMPPIPE_RESTRICT/RESTRICT/gi 5 years ago
Michael Santos 7dda5bafcd sandbox->restrict_process 5 years ago
Michael Santos fa88bc9f6d seccomp: allow running on termux 5 years ago
Michael Santos d708ce27b9 sandbox: fix pledge on openbsd 6.6 5 years ago
Michael Santos abfa336640 xmppipe_uuid_gen: xmpp_uuid_gen NULL check wrapper 5 years ago
Michael Santos ad1bf58c55 xmppipe_send: move internal functions 5 years ago
Michael Santos 31d6a03bfc XEP-0363: HTTP File Upload
Add initial support for XEP-0363. HTTP uploads can be used when colon
separated values for stdin is enabled:

~~~

u::::<filename>|<size (bytes)>[|<content-type>]

u::::example.png%7C16698

u::::tr.png%7C16698%7Cimage%2Fpng
~~~

The reponse:

~~~
U:upload.example.com:user@example.com/477937350262208314215778:https%3A%2F%2Fexample.com%2Fupload%2F1234%2Fabc%2Fexample.png%7Chttps%3A%2F%2Fexample.com%2Fupload%2F1234%2Fabc%2Fexample.png
~~~

TODO:

* support PUT header elements
* support/test error conditions

Questions:

* save the maximum file size returned by the server and disallow uploads
  larger than the value?

* xmppipe is "pinned" to the upload server returned in the IQ reply (the
  "to" field is ignored)

  * allow other upload servers?
  * error if different upload server is specified in "u:<from>:<to>"?
5 years ago
Michael Santos 11bc581608 oob inline image: u -> I 5 years ago
Michael Santos 3119d639ca version: add child stanza before release 5 years ago
Michael Santos cb21c2860e Support inline images
When using the csv input format, add a new format ('u') that wraps the
message in an "x:oob" element. The image will be displayed inline by
Conversations.

~~~
u:groupchat:::https%3A%2F%2Fhttpstatusdogs.com%2Fimg%2F500.jpg
~~~
5 years ago
Michael Santos 5f2c3003ff v0.13.0
Update usage with --format option.
5 years ago
Michael Santos a45b734211 options: remove --chat-marker 5 years ago
Michael Santos 2a75c3373a Always display chat markers
Remove the option to explicitly enable/disable chat markers.
5 years ago
Michael Santos 997fc6a102 version: fix double free
Fix segfault from pasto when releasing stanza.
5 years ago
Michael Santos 5e488e059a xmpp_conn_set_flags() argument is a long
Correct the type for the flag argument from int to long. Note the
compiler will still complain because, although xmpp_conn_set_flags() is
declared to take a signed long, the constants are declared as unsigned
longs:

src/xmppipe.c: In function ‘main’:
src/xmppipe.c:205:13: warning: conversion to ‘long unsigned int’ from
‘long int’ may change the sign of the result [-Wsign-conversion]
       flags |= XMPP_CONN_FLAG_TRUST_TLS;
             ^
src/xmppipe.c:205:16: warning: conversion to ‘long int’ from ‘long
unsigned int’ may change the sign of the result [-Wsign-conversion]
       flags |= XMPP_CONN_FLAG_TRUST_TLS;
5 years ago
Michael Santos 8776afe0f5 Suppress conversion warnings 5 years ago
Michael Santos 134d3599ce stream_management: warning: cast strotonum() result 5 years ago
Michael Santos c8774e591c strtonum: fix prototype warning 5 years ago
Michael Santos 396188ea87 xmppipe.h: fix prototype 5 years ago
Michael Santos a21d4d5b29 xmppipe_send: remove shadowed variable 5 years ago
Michael Santos 42e0ce4a67 xmppipe: free child stanzas 5 years ago
Michael Santos 2f4e1459e9 version: free stanza on error 5 years ago
Michael Santos c4de097c6b ping: free child stanza 5 years ago
Michael Santos e4e78775be muc: free child stanzas 5 years ago
Michael Santos 287bb92aee vesion: free allocated stanzas 5 years ago
Michael Santos 1bb03b563e xmppipe_send_message: fix memory leak
Fix a memory leak caused by improper usage of
xmpp_stanza_new()/xmpp_stanza_release() by replacing usage with the
simpler xmpp_message_new()/xmpp_message_set_body() API available in
libstrophe 0.9.0, as advised by @pasis.

Fixes https://github.com/msantos/xmppipe/issues/3.
5 years ago
Michael Santos 8792a8a05c Mark fun as static 5 years ago
Michael Santos e00a7fddd2 Consistently format using clang-format 5 years ago
Michael Santos 4b85976242 --keepalives -> --keepalive 5 years ago
Michael Santos 7793b0ac07 Fix pasto in -k/--keepalive 5 years ago
Michael Santos 8e2fd1c363 xmppipe_conn_fd: check fd is a socket 5 years ago
Michael Santos b3991577aa reorg: event_loop: move to separate file 5 years ago
Michael Santos a8cc5b730a Remove unused function declaration 5 years ago
Michael Santos 4081ab67cb reorg: muc_unlock 5 years ago
Michael Santos 5165f8a1a4 reorg: muc_subject 5 years ago
Michael Santos 9d6b58ba26 reorg: muc: join 5 years ago
Michael Santos 6731de9a13 reorg: ping 5 years ago
Michael Santos 17e40ad118 reorg: move stream_close with other stream ops 5 years ago
Michael Santos 0ba9e92eda reorg: stream management: ack 5 years ago
Michael Santos ee0f59516b reorg: stream_close: move to util for now 5 years ago
Michael Santos 862ab6d313 reorg: stream management: request 5 years ago
Michael Santos 5cb7647e75 reorg: stream management: check if enabled 5 years ago
Michael Santos c5f0f7b662 reorg: presence error handler 5 years ago
Michael Santos 0b22ad4302 reorg: presence handler 5 years ago
Michael Santos 8b1374a25a reorg: move next_state to util 5 years ago
Michael Santos d150e63735 reorg: null handler 5 years ago
Michael Santos b3468de16f reorg: ping handler 5 years ago
Michael Santos 9a98b8b9bf reorg: version handler 5 years ago
Michael Santos 895ad40ee2 reorg: xmppipe_send* 5 years ago
Michael Santos a365e18b59 reorg: message: organize by handler 5 years ago
Michael Santos 561fc9cbc3 xmppipe_roomname: clean up 5 years ago
Michael Santos 990874ef2e Add support for printing groupchat subject 5 years ago
Michael Santos 4e660c641a --keepalive-failures: check minimum using strtonum() 5 years ago
Michael Santos b38d4b9e0c handle_message: use xmpp_free() 5 years ago
Michael Santos 026890d377 Add experimental support for chat markers
Support chat marker (XEP-0333) stanzas when the "--chat-marker" switch
is provided on the command line. A chat marker is prefixed by 'M':

~~~
M:groupchat:test@conference.example.com/msantos:me@example.com/162315501161646113068402:
~~~

The idea is to allow scripts to react based on whether a message has
been read, for example, escalating via other channels.
5 years ago
Michael Santos 501ada87ff chat: set default user to self 5 years ago
Michael Santos a10b4bd84c chat: fix segfault when checking origin
strcmp(3) segfaulted when comparing the from address to NULL.

Checking messages originated from the output account only makes sense
with groupchat. Remove the check for type of "chat".
6 years ago
Michael Santos dbbf6e5f5e seccomp: update for Ubuntu 18.04
Add new syscalls (getrandom).

The resolver now uses openat(2) and sendmsg(2).
6 years ago
Michael Santos 0a776e3441 Fix warning
src/xmppipe.c:69:19: warning: duplicate ‘const’ declaration specifier
[-Wduplicate-decl-specifier]
 static const char const *xmppipe_states[] = {
                   ^~~~~
6 years ago
Michael Santos a2d16c90c1 format: rename options
stdin -> text, colon -> csv
6 years ago
Michael Santos df6a7ee596 format: use separate function 6 years ago
Michael Santos ab6d1b3f79 format: clean up input parsing 6 years ago
Michael Santos 4d1423eb5e <Remove unused verbose log
Statement will never be called since verbose mode is set afterwards.
6 years ago
Michael Santos 06f50d4b11 Fix "-x/--base64" option 6 years ago
Michael Santos ff3249c391 Revert "capsicum: allow terminal events"
This reverts commit 7090ef09fb.

fstat/ioctl are checking whether the program is attached to tty for
setting buffering. Since xmppipe explicitly enables line buffering, the
capsicum sandbox can ignore these tests.
6 years ago
Michael Santos 7090ef09fb capsicum: allow terminal events 6 years ago
Michael Santos 91173ecc00 xmppipe_fmt -> xmppipe_fmt_encode 6 years ago
Michael Santos 9598e01579 format: use empty element to set default values
An empty string in the type, to and from uses a default value. For
example to send a message to the groupchat specified on the command
line:

~~~

m::::this is a test message
~~~
6 years ago
Michael Santos 231bee7c74 -f/--format: support percent decoding
Convert percent hexcodes when format mode is enabled:

    m:chat:to@example.com:from@example.com:01234=%30%31%32%33%34
6 years ago
Michael Santos 5127b271ba -f/--format: fix arguments 6 years ago
Michael Santos 22afb52f83 --format/-f: formatted input
Rough implementation to allow input to be formatted as colon separated
values in the same way as output:

* percent decoding of the input is not supported yet
* only message stanzas supported

Using formatted input lets the script respond to other users aside from
the default channel assigned to stdout:

~~~
m:chat:to@example.com:from@example.com:message-body
~~~

TODO:
* does the default stdout channel always need to be formatted?

~~~
m:chat:to@example.com:from@example.com:message-body
m:groupchat:default@conference.example.com:from@example.com:message-body
~~~

  Otherwise it could be ambiguous.

* support presence and iq stanzas

  For example, a bot could respond to groupchat invitations.

* percent decoding: require the input to be percent encoded

  Support binary and multiline data.

* format naming: choose better names for the format types
6 years ago
Michael Santos dff8b8f72e sandbox/seccomp: return value from prctl(2) 6 years ago
Michael Santos ba2d49e4bd Use argument as output JID
Instead of supplying the output JID as an optional argument:

    xmppipe --output foo@conference.example.com

Use the first argument:

    xmppipe foo@conference.example.com

The -o/--output switches are still accepted.
6 years ago
Michael Santos c7eb9a1d71 Check for NULL before calling libstrophe 6 years ago
Michael Santos 25dbece040 chat: fix segfault when domain is not provided
Running xmppipe in chat mode without a full jid:

    xmppipe --chat --output foo

Caused a segfault when a NULL domain was passed to
xmpp_stanza_set_attribute(). The libstrophe functions do not check for
NULL and so crash calling strlen(NULL).

Set the jid's domain from the user's username. If the user's jid is
user@example.com:

    # expanded to foo@example.com
    xmppipe --chat --output foo
6 years ago
Michael Santos 29280e2edc Document --chat option
Document usage of one to one chat:

    xmppipe --chat --output me@example.com

Only provide the long option until a few quirks have been worked out:

* if only a username is provided, it will be expanded to a conference
  name

    # expands to me@conference.example.com
    xmppipe --chat --output me

* should "normal" and "headline" message types also be supported?

* tests
6 years ago
Michael Santos 3f7ef5ca7b debug: print state names 6 years ago
Michael Santos de9fa9ab30 Fixes for ejabberd 18.04
* always add id in iq stanzas.

* presence: response from muc may contain more than one 'x' element,
  match stanza by namespace

* debug: print out current state
6 years ago
Michael Santos 47102efc69 Set line buffered mode 6 years ago
Michael Santos 97fa38c86a Support one-to-one chats
Add preliminary support to one to one chats. No XEPs were read in the
preparation of this change:

    xmppipe -C example@example.com

TODO
* clean up
    * state change is hardcoded
    * if (GROUPCHAT) branches
* autodetect MUC
* in chat mode, ctrl-D can cause a loop
6 years ago
Michael Santos 4a8d1f910f xmppipe_conn_fd: get highest open fd 6 years ago
Michael Santos 3797fc4151 macosx: fix compile errors 6 years ago
Michael Santos 38cd570d28 seccomp: allow restart_syscall in stdin sandbox 6 years ago
Michael Santos cc828f582f seccomp: allow restart_syscall 6 years ago
Michael Santos 9ae3dcc1a1 seccomp: raspbian: allow futex(2), sysinfo(2) 6 years ago
Michael Santos 2d67d64ecb Bump version to 0.9.3 7 years ago
Michael Santos 2933964bca capscicum: return result of setlrimit() 7 years ago
Michael Santos 3e1eea1069 sandbox/rlimit: return value of setrlimit() 7 years ago
Michael Santos 60895c46e4 README: use long options, bump version
Bump version for sandbox compilation changes.
7 years ago
Michael Santos ec32315684 sandbox: use the lowercase name for configuration 7 years ago
Michael Santos f0092fd58a seccomp: adjust header for syscalls 7 years ago
Michael Santos fa2ebb799d Use libstrophe base64 support
Use the base64 interface in libstrophe for encoding/decoding instead of
the undocumented interfaces in libresolv.
7 years ago
Michael Santos e28f208103 Optionally disable TLS cert verification 7 years ago
Michael Santos 3fa5755655 sandbox/rlimit: remove redundant code, ifdef's 7 years ago
Dmitry Podgorny cca644045f Fix getting wrong attribute from stanza 7 years ago