Expand ~ in paths to the user's home directory #2

Closed
opened 2026-10-05 03:52:29 +02:00 by adam · 6 comments
Owner

Currently if you, for example, specify ~/.oidentd.conf as a path to .oidentd.conf (which is the default setting btw) this will fail. ZNC requires full paths, like /home/user/.oidentd.conf.

Currently if you, for example, specify ~/.oidentd.conf as a path to .oidentd.conf (which is the default setting btw) this will fail. ZNC requires full paths, like /home/user/.oidentd.conf. <!-- github-sync-id:607025 -->
adam closed this issue 2026-10-05 03:52:29 +02:00
Author
Owner
$ grep ISpoofFile ~/.znc/configs/znc.conf
ISpoofFile   = ~/.oidentd.conf

and
$ ./znc --debug | grep ISpoofFile
Writing [global { reply "psy" }] to ISpoofFile [/home/psychon/.oidentd.conf]
Why does this work here? Does this have anything to do with it?
$ echo $HOME
/home/psychon

``` $ grep ISpoofFile ~/.znc/configs/znc.conf ISpoofFile = ~/.oidentd.conf ``` and $ ./znc --debug | grep ISpoofFile Writing [global { reply "psy" }] to ISpoofFile [/home/psychon/.oidentd.conf] Why does this work here? Does this have anything to do with it? $ echo $HOME /home/psychon <!-- github-comment-id:783405 -->
Author
Owner

DoesNotWorkForMe :p

I just changed ISpoofFile to ~/.oidentd.conf again and then this happens:
-> /znc connect

[2011/02/18-02:34:31] *status: Jumping to the next server in the list...

[2011/02/18-02:34:32] *status: Disconnected from IRC. Reconnecting...

[2011/02/18-02:34:32] *status: ISpoof [~/.oidentd.conf] could not be written, retrying...

[2011/02/18-02:34:42] *status: ISpoof [~/.oidentd.conf] could not be written, retrying...

[2011/02/18-02:34:52] *status: ISpoof [~/.oidentd.conf] could not be written, retrying...

...

Maybe the current method for finding ~ isn't totally multiplatform-compatible?
My operating system is Fedora 10 (32-bit) by the way.

"echo $HOME" works, yes.

If I put the full path again then it works again. Strange that it works for you.

(I have yet to try it with --debug to see what it says.)

DoesNotWorkForMe :p I just changed ISpoofFile to ~/.oidentd.conf again and then this happens: -> /znc connect [2011/02/18-02:34:31] *status: Jumping to the next server in the list... [2011/02/18-02:34:32] *status: Disconnected from IRC. Reconnecting... [2011/02/18-02:34:32] *status: ISpoof [~/.oidentd.conf] could not be written, retrying... [2011/02/18-02:34:42] *status: ISpoof [~/.oidentd.conf] could not be written, retrying... [2011/02/18-02:34:52] *status: ISpoof [~/.oidentd.conf] could not be written, retrying... ... Maybe the current method for finding ~ isn't totally multiplatform-compatible? My operating system is Fedora 10 (32-bit) by the way. "echo $HOME" works, yes. If I put the full path again then it works again. Strange that it works for you. (I have yet to try it with --debug to see what it says.) <!-- github-comment-id:784256 -->
Author
Owner

I just remembered that the "Writing..." line was added to the --debug output after 0.096, so perhaps your znc doesn't have that... :(

I just remembered that the "Writing..." line was added to the `--debug` output after 0.096, so perhaps your znc doesn't have that... :( <!-- github-comment-id:785321 -->
Author
Owner

I'm running r2270-SVN-20110118 (0.097), but that doesn't matter then, I'll upgrade it anyway, and then we can hopefuly find the problem. :)

I'm running r2270-SVN-20110118 (0.097), but that doesn't matter then, I'll upgrade it anyway, and then we can hopefuly find the problem. :) <!-- github-comment-id:785334 -->
Author
Owner

I have just upgraded ZNC to latest Git (080bf67) and have messed around a bit.

It seems that if you put for example ~/.oidentd.conf and click Save, that it is written as such to znc.conf, but I have found that when ZNC is restarted or rehashed that it expands the ~/.oidentd.conf to the full path (/home/user/.oidentd.conf) and if the config then gets rewritten for whatever reason it also saves it with that full path to znc.conf. So changing this on the fly and not rehashing causes problems like I had above.

This raises the question: Why do this? Why have the ~ only be parsed on rehash and not on save? Why even do this at all? Maybe better to have ZNC save and parse ~ all the time, regardless of rehash/restart. That's also easier for moving ZNC's datadir from one machine to another and keep paths with a ~ in the config without needing to change those (SSLCertFile and ISpoofFile).

I have just upgraded ZNC to latest Git (080bf67) and have messed around a bit. It seems that if you put for example ~/.oidentd.conf and click Save, that it is written as such to znc.conf, but I have found that when ZNC is restarted or rehashed that it expands the ~/.oidentd.conf to the full path (/home/user/.oidentd.conf) and if the config then gets rewritten for whatever reason it also saves it with that full path to znc.conf. So changing this on the fly and not rehashing causes problems like I had above. This raises the question: Why do this? Why have the ~ only be parsed on rehash and not on save? Why even do this at all? Maybe better to have ZNC save and parse ~ all the time, regardless of rehash/restart. That's also easier for moving ZNC's datadir from one machine to another and keep paths with a ~ in the config without needing to change those (SSLCertFile and ISpoofFile). <!-- github-comment-id:789956 -->
Author
Owner

Ah, I always tested this by editing ~/.znc/configs/znc.conf before starting znc. It never occured to me (and no one mentioned it!) that others set this via webadmin.

The config reading did handle the leading "~", but webadmin obviously didn't. I now moved this to the generic "read/write some file"-code.

Thanks for finally figuring out where the problem is!

Ah, I always tested this by editing ~/.znc/configs/znc.conf before starting znc. It never occured to me (and no one mentioned it!) that others set this via webadmin. The config reading did handle the leading "~", but webadmin obviously didn't. I now moved this to the generic "read/write some file"-code. Thanks for finally figuring out where the problem is! <!-- github-comment-id:790155 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#2