Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config parser complains over temp file created by Emacs #5061

Closed
olberger opened this issue Mar 14, 2017 · 6 comments
Closed

Config parser complains over temp file created by Emacs #5061

olberger opened this issue Mar 14, 2017 · 6 comments
Labels
area/configuration DSL, parser, compiler, error handling

Comments

@olberger
Copy link

I've been editing with Emacs a config file within /etc/icinga2/conf.d/hosts/ named esther.conf. This results in a symlink being created there as .#esther.conf until the file is saved.

This results in a crash of the parser when restarting Icinga 2:

[2017-03-14 10:49:03 +0100] critical/config: 
Config error: /tmp/buildd/icinga2-2.1.1/lib/config/configcompiler.cpp(201): Throw in function static void icinga::ConfigCompiler::CompileFile(const icinga::String&, const icinga::String&)
Dynamic exception type: N5boost16exception_detail10clone_implIN6icinga11posix_errorEEE
std::exception::what: std::exception
[PN6icinga10StackTraceE] = 
        (0) libbase.so: void boost::throw_exception<icinga::posix_error>(icinga::posix_error const&) (+0xce) [0x7f6825414a5e]
        (1) libconfig.so: icinga::ConfigCompiler::CompileFile(icinga::String const&, icinga::String const&) (+0x4af) [0x7f68250f9c6f]
        (2) libbase.so: icinga::Utility::GlobRecursive(icinga::String const&, icinga::String const&, boost::function<void (icinga::String const&)> const&, int) (+0x2ee) [0x7f6825484ade]
        (3) libbase.so: icinga::Utility::GlobRecursive(icinga::String const&, icinga::String const&, boost::function<void (icinga::String const&)> const&, int) (+0x39e) [0x7f6825484b8e]
        (4) libconfig.so: icinga::ConfigCompiler::HandleIncludeRecursive(icinga::String const&, icinga::String const&, icinga::DebugInfo const&) (+0x280) [0x7f68250f8a90]
        (5) libconfig.so: yyparse(icinga::ConfigCompiler*) (+0x3622) [0x7f68251138b2]
        (6) libconfig.so: icinga::ConfigCompiler::Compile() (+0xa9) [0x7f6825118499]
        (7) libconfig.so: icinga::ConfigCompiler::CompileStream(icinga::String const&, std::istream*, icinga::String const&) (+0xbf) [0x7f68250f837f]
        (8) libconfig.so: icinga::ConfigCompiler::CompileFile(icinga::String const&, icinga::String const&) (+0x24d) [0x7f68250f9a0d]
        (9) icinga2: Main() (+0x18bf) [0x41c06f]
        (10) icinga2: main (+0x24) [0x419c74]
        (11) libc.so.6: __libc_start_main (+0xf5) [0x7f6823668b45]
        (12) /usr/sbin/icinga2() [0x419da9]


[PN6icinga12ContextTraceE] = 
        (0) Compiling configuration file '/etc/icinga2/conf.d/hosts/.#esther.conf'
        (1) Compiling configuration stream with name '/etc/icinga2/icinga2.conf'
        (2) Compiling configuration file '/etc/icinga2/icinga2.conf'

2, "No such file or directory"[PN5boost18errinfo_file_name_E] = /etc/icinga2/conf.d/hosts/.#esther.conf
[PN5boost21errinfo_api_function_E] = std::ifstream::open

[2017-03-14 10:49:03 +0100] critical/config: 1 errors, 0 warnings.

I guess such temporary "hidden" lock/temp symlinks should be skipped.

Hope this helps.

@dnsmichi
Copy link
Contributor

Symlinks should be followed, that feature request was implemented a while ago. Other than that the format is still valid, even for hidden files on Linux-based systems.

How exactly does such a file and its attribute look like?

Please show the output of

ls -lah /etc/icinga2/conf.d/hosts

@dnsmichi dnsmichi added area/configuration DSL, parser, compiler, error handling needs feedback We'll only proceed once we hear from you again labels Mar 14, 2017
@gunnarbeutner
Copy link
Contributor

This kind of feels like an oversight in Emacs. Icinga really only does what it's being told to, i.e. to include all files whose names match the pattern "*.conf".

I'm uncertain whether we should work around this issue in Icinga. At the same time I'm also wondering whether other applications (e.g. Apache) show similar behavior. Vim has enough foresight to use the '.swp' extension for its temporary files, probably to avoid this exact same problem.

In the meantime http://stackoverflow.com/questions/151945/how-do-i-control-how-emacs-makes-backup-files has a workaround for this, i.e. to use a different directory for those temporary files.

@olberger
Copy link
Author

@dnsmichi here's the ls:

# ls -alh /etc/icinga2/conf.d/hosts/
total 24K
drwxr-xr-x 3 root root 4.0K Mar 15 17:14 .
lrwxrwxrwx 1 root root   28 Mar 15 17:14 .#esther.conf -> root@kilauea.8869:1489159668
drwxr-xr-x 3 root root 4.0K Mar 10 16:52 ..
-rw-r--r-- 1 root root  258 Mar 14 10:50 esther.conf
-rw-r--r-- 1 root root    0 Mar 10 17:15 esther.conf~
...
drwxr-xr-x 2 root root 4.0K Mar 10 16:52 localhost
-rw-r--r-- 1 root root  322 Sep 18  2014 localhost.conf

Maybe the ".conf" regex should be interpreted as any file ending in .conf and not starting with a dot (kinda [^\.] or something like this). The convention of using . as a first character for hidden files may apply quite well in this respect as I'd expect a sysadmin to not hide configuration files inside /etc... but there may be other habits in strange communities ? ;)

I guess there should probably be libs allowing that, and indeed @gunnarbeutner how apache behaves in this case could be woth checking.

Thanks for caring.

@dnsmichi
Copy link
Contributor

Ok, understood. I guess Apache reads "hidden" files too, think of .htaccess and so on. I haven't looked into its source code though. I found another issue on the Logstash tracker which discusses parsing such temporary files: elastic/logstash#2271

Yet I'm not certain how one could workaround that emacs specific file type. It might be worthwhile to check whether emacs can be configured to use a different suffix for temporary files. Or specifically use a different backup location.

@gunnarbeutner
Copy link
Contributor

FWIW I'm strongly opposed to adding editor-specific workarounds.

@dnsmichi
Copy link
Contributor

I'd say users should be able to change the auto-save/backup file location, like described here: http://ergoemacs.org/emacs/emacs_set_backup_into_a_directory.html

Such files might also affect backups and other applications, and instead of tinkering with each application having trouble with it, I'd find a way to handle that on a global basis. At least I'd do that on my systems because I dislike such specialities driving me nuts :)

@dnsmichi dnsmichi removed the needs feedback We'll only proceed once we hear from you again label May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration DSL, parser, compiler, error handling
Projects
None yet
Development

No branches or pull requests

3 participants