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

dir: hang at resolving when in chroot #1455

Closed
markus2330 opened this issue Apr 7, 2017 · 0 comments
Closed

dir: hang at resolving when in chroot #1455

markus2330 opened this issue Apr 7, 2017 · 0 comments
Milestone

Comments

@markus2330
Copy link
Contributor

markus2330 commented Apr 7, 2017

Describe what you wanted to do

Patched ls to do a chroot before kdbOpen:

--- a/src/tools/kdb/ls.cpp
+++ b/src/tools/kdb/ls.cpp
@@ -14,10 +14,13 @@
 #include <kdb.hpp>
 #include <keysetio.hpp>
 
+#include <unistd.h>
+
+
 using namespace kdb;
 using namespace std;
 
-LsCommand::LsCommand () : kdb (root)
+LsCommand::LsCommand ()
 {
 }
 
@@ -28,12 +31,17 @@ int LsCommand::execute (Cmdline const & cl)
                throw invalid_argument ("1 argument required");
        }
 
-       printWarnings (cerr, root);
 
-       root = cl.createKey (0);
+       chroot ("/tmp");
+       {
+       kdb::Key root = cl.createKey (0);
+       kdb::KDB kdb (root);
+       kdb::KeySet ks;
 
        kdb.get (ks, root);
 
+       printWarnings (cerr, root);
+
        if (cl.verbose) cout << "size of all keys in mountpoint: " << ks.size () << endl;
 
        KeySet part (ks.cut (root));
@@ -48,6 +56,7 @@ int LsCommand::execute (Cmdline const & cl)
        cout << part;
 
        printWarnings (cerr, root);
+       }
 
        return 0;
 }
diff --git a/src/tools/kdb/ls.hpp b/src/tools/kdb/ls.hpp
index 01dc588..c81ac00 100644
--- a/src/tools/kdb/ls.hpp
+++ b/src/tools/kdb/ls.hpp
@@ -15,10 +15,6 @@
 
 class LsCommand : public Command
 {
-       kdb::Key root;
-       kdb::KDB kdb;
-       kdb::KeySet ks;
-
 public:
        LsCommand ();
        ~LsCommand ();

Describe what you expected

That sudo kdb ls / does ls in the new chroot.

Describe what actually happened

Hang in endless loop in elektraResolveDir, in src/plugins/resolver/filename.c because the dir will never get equal /.

Workaround: disable dir resolving. (e.g. uncommenting elektraResolveDir)

System Information

  • Elektra Version: master

Further Log Files and Output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant