#631 Let data_path be relative when Prosody is installed
Reporter
kousu
Owner
MattJ
Created
Updated
Stars
★ (1)
Tags
Type-Enhancement
Priority-Medium
Status-Accepted
kousu
on
I'm trying to set up prosody for unit testing. I want to have a bunch of config files for different situations that I can swap at will. I've found that if `data_path` is non-absolute, prosody fails with 'file not found' trying to do almost anything, which is confusing because if I paste the path in from the same shell it works ((if I've explicitly made the file somehow first, e.g. by using an absolute path temporarily)). If your file openers are expecting absolute paths, they should say that instead of "No such file or directory". I would prefer, though, if relative paths were allowed, so that I could run multiple prosodies with the same config file just by changing their working directory. Otherwise I will have to get into generating config files and that's a sad rabbit hole.
Here's what I'm working with:
```
-- Prosody configuration file for standalone testing
daemonize = false
data_path = "test/prosody"
pid_file = ".prosody.pid"
---------- Server-wide settings ----------
-- Settings in this section apply to the whole server and are the default settings
-- for any virtual hosts
-- This is a (by default, empty) list of accounts that are admins
-- for the server. Note that you must create the accounts separately
-- (see http://prosody.im/doc/creating_accounts for info)
-- Example: admins = { "user1@example.com", "user2@example.net" }
admins = { }
-- This is the list of modules Prosody will load on startup.
-- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too.
-- Documentation on modules can be found at: http://prosody.im/doc/modules
modules_enabled = {
-- Generally required
"roster"; -- Allow users to have a roster. Recommended ;)
"saslauth"; -- Authentication for clients and servers. Recommended if you want to log in.
"tls"; -- Add support for secure TLS on c2s/s2s connections
"dialback"; -- s2s dialback support
"disco"; -- Service discovery
-- Not essential, but recommended
"private"; -- Private XML storage (for room bookmarks, etc.)
"vcard"; -- Allow users to set vCards
-- These are commented by default as they have a performance impact
--"privacy"; -- Support privacy lists
--"compression"; -- Stream compression
-- Nice to have
"version"; -- Replies to server version requests
"uptime"; -- Report how long server has been running
"time"; -- Let others know the time here on this server
"ping"; -- Replies to XMPP pings with pongs
"pep"; -- Enables users to publish their mood, activity, playing music and more
"register"; -- Allow users to register on this server using a client and change passwords
-- Admin interfaces
"admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands
--"admin_telnet"; -- Opens telnet console interface on localhost port 5582
-- HTTP modules
--"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP"
--"http_files"; -- Serve static files from a directory over HTTP
-- Other specific functionality
"posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
--"groups"; -- Shared roster support
--"announce"; -- Send announcement to all online users
--"welcome"; -- Welcome users who register accounts
--"watchregistrations"; -- Alert admins of registrations
--"motd"; -- Send a message to users when they log in
--"legacyauth"; -- Legacy authentication. Only used by some old clients and bots.
};
allow_registration = true;
c2s_require_encryption = false
s2s_secure_auth = false
s2s_require_encryption = false
authentication = "internal_plain"
log = {
"*console";
}
component_ports = { 5347 }
----------- Virtual hosts -----------
-- You need to add a VirtualHost entry for each domain you wish Prosody to serve.
-- Settings under each VirtualHost entry apply *only* to that host.
VirtualHost "galleon"
------ Components ------
-- a standard XEP0045 chat server: this is available for comparing protocols
Component "conference.galleon" "muc"
-- This is where the external component hooks in to provide the IRC transport
Component "irc.galleon"
component_secret = "secret"
```
And here's what I see:
```
[kousu@galleon ircgate]$ prosodyctl --config test/prosody.cfg.lua register saul galleon secret
datamanager error Unable to write to accounts storage ('test/prosody/galleon/accounts/saul.dat~: No such file or directory') for user: saul@galleon
```
If i change it to
```
data_path = "/home/kousu/src/comms/ircgate/test/prosody"
```
Then it works:
```
[kousu@galleon ircgate]$ prosodyctl --config test/prosody.cfg.lua register saul galleon secret
[kousu@galleon ircgate]$ ls -l test/prosody/galleon/
total 4
drwxr-xr-x 2 kousu kousu 4096 Feb 21 02:24 accounts
[kousu@galleon ircgate]$ ls -l test/prosody/galleon/accounts/saul.dat
-rw-r----- 1 kousu kousu 38 Feb 21 02:24 test/prosody/galleon/accounts/saul.dat
```
MattJ
on
Hi, thanks for the detailed report!
I was confused at first, because I use relative data paths all the time. But I realised what is going on...
Relative data paths are *not* supported when you have `make install`ed Prosody. When Prosody is "installed", it no longer relies on where it was started. All paths (that aren't handled specially) are treated as relative to the data directory.
Of course this means a relative data_path won't work, because it treats "test/prosody" as "test/prosody/test/prosody".
You might want to consider not `make install`ing Prosody, given what I know of your use-case. You can run Prosody directly from its source tree after `make` (i.e. `./prosodyctl`), and this makes a nice self-contained copy of Prosody by default (and in this situation, relative data paths work 100%). This also makes it easy to have multiple Prosody versions side-by-side, etc.
I will give some more thought to this issue (the current behaviour of a relative data_path on an installed Prosody is definitely a bit weird, and not by design). I'd like to make it consistent, even if that means disallowing it entirely. The philosophy of the "installed" Prosody is that it should work consistently regardless of its initial startup environment.
Would like to hear your thoughts on everything above :)
Changes
owner MattJ
titleLet data_path be relative Let data_path be relative when Prosody is installed
MattJ
on
Thoughts: either make it relative to the config file, or disallow relative paths.
I'm trying to set up prosody for unit testing. I want to have a bunch of config files for different situations that I can swap at will. I've found that if `data_path` is non-absolute, prosody fails with 'file not found' trying to do almost anything, which is confusing because if I paste the path in from the same shell it works ((if I've explicitly made the file somehow first, e.g. by using an absolute path temporarily)). If your file openers are expecting absolute paths, they should say that instead of "No such file or directory". I would prefer, though, if relative paths were allowed, so that I could run multiple prosodies with the same config file just by changing their working directory. Otherwise I will have to get into generating config files and that's a sad rabbit hole. Here's what I'm working with: ``` -- Prosody configuration file for standalone testing daemonize = false data_path = "test/prosody" pid_file = ".prosody.pid" ---------- Server-wide settings ---------- -- Settings in this section apply to the whole server and are the default settings -- for any virtual hosts -- This is a (by default, empty) list of accounts that are admins -- for the server. Note that you must create the accounts separately -- (see http://prosody.im/doc/creating_accounts for info) -- Example: admins = { "user1@example.com", "user2@example.net" } admins = { } -- This is the list of modules Prosody will load on startup. -- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too. -- Documentation on modules can be found at: http://prosody.im/doc/modules modules_enabled = { -- Generally required "roster"; -- Allow users to have a roster. Recommended ;) "saslauth"; -- Authentication for clients and servers. Recommended if you want to log in. "tls"; -- Add support for secure TLS on c2s/s2s connections "dialback"; -- s2s dialback support "disco"; -- Service discovery -- Not essential, but recommended "private"; -- Private XML storage (for room bookmarks, etc.) "vcard"; -- Allow users to set vCards -- These are commented by default as they have a performance impact --"privacy"; -- Support privacy lists --"compression"; -- Stream compression -- Nice to have "version"; -- Replies to server version requests "uptime"; -- Report how long server has been running "time"; -- Let others know the time here on this server "ping"; -- Replies to XMPP pings with pongs "pep"; -- Enables users to publish their mood, activity, playing music and more "register"; -- Allow users to register on this server using a client and change passwords -- Admin interfaces "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands --"admin_telnet"; -- Opens telnet console interface on localhost port 5582 -- HTTP modules --"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP" --"http_files"; -- Serve static files from a directory over HTTP -- Other specific functionality "posix"; -- POSIX functionality, sends server to background, enables syslog, etc. --"groups"; -- Shared roster support --"announce"; -- Send announcement to all online users --"welcome"; -- Welcome users who register accounts --"watchregistrations"; -- Alert admins of registrations --"motd"; -- Send a message to users when they log in --"legacyauth"; -- Legacy authentication. Only used by some old clients and bots. }; allow_registration = true; c2s_require_encryption = false s2s_secure_auth = false s2s_require_encryption = false authentication = "internal_plain" log = { "*console"; } component_ports = { 5347 } ----------- Virtual hosts ----------- -- You need to add a VirtualHost entry for each domain you wish Prosody to serve. -- Settings under each VirtualHost entry apply *only* to that host. VirtualHost "galleon" ------ Components ------ -- a standard XEP0045 chat server: this is available for comparing protocols Component "conference.galleon" "muc" -- This is where the external component hooks in to provide the IRC transport Component "irc.galleon" component_secret = "secret" ``` And here's what I see: ``` [kousu@galleon ircgate]$ prosodyctl --config test/prosody.cfg.lua register saul galleon secret datamanager error Unable to write to accounts storage ('test/prosody/galleon/accounts/saul.dat~: No such file or directory') for user: saul@galleon ``` If i change it to ``` data_path = "/home/kousu/src/comms/ircgate/test/prosody" ``` Then it works: ``` [kousu@galleon ircgate]$ prosodyctl --config test/prosody.cfg.lua register saul galleon secret [kousu@galleon ircgate]$ ls -l test/prosody/galleon/ total 4 drwxr-xr-x 2 kousu kousu 4096 Feb 21 02:24 accounts [kousu@galleon ircgate]$ ls -l test/prosody/galleon/accounts/saul.dat -rw-r----- 1 kousu kousu 38 Feb 21 02:24 test/prosody/galleon/accounts/saul.dat ```
Hi, thanks for the detailed report! I was confused at first, because I use relative data paths all the time. But I realised what is going on... Relative data paths are *not* supported when you have `make install`ed Prosody. When Prosody is "installed", it no longer relies on where it was started. All paths (that aren't handled specially) are treated as relative to the data directory. Of course this means a relative data_path won't work, because it treats "test/prosody" as "test/prosody/test/prosody". You might want to consider not `make install`ing Prosody, given what I know of your use-case. You can run Prosody directly from its source tree after `make` (i.e. `./prosodyctl`), and this makes a nice self-contained copy of Prosody by default (and in this situation, relative data paths work 100%). This also makes it easy to have multiple Prosody versions side-by-side, etc. I will give some more thought to this issue (the current behaviour of a relative data_path on an installed Prosody is definitely a bit weird, and not by design). I'd like to make it consistent, even if that means disallowing it entirely. The philosophy of the "installed" Prosody is that it should work consistently regardless of its initial startup environment. Would like to hear your thoughts on everything above :)
ChangesLet data_path be relativeLet data_path be relative when Prosody is installedThoughts: either make it relative to the config file, or disallow relative paths.
Changes