GithubHelp home page GithubHelp logo

Comments (7)

kahatlen avatar kahatlen commented on July 20, 2024

I haven't tested recently, but I think the default behaviour is to follow symlinks only if they are direct children of the source root directory. Symlinks further down in the directory structure are not followed.

from opengrok.

jelinson avatar jelinson commented on July 20, 2024

👍

from opengrok.

tarzanek avatar tarzanek commented on July 20, 2024

is this somehow related to #689 ?

from opengrok.

vladak avatar vladak commented on July 20, 2024

@kahatlen : yep, this is the case, index/Indexer.java:main() contains:

524                // automatically allow symlinks that are directly in source root
525                String file = cfg.getSourceRoot();
526                if (file != null) {
527                    File sourceRootFile = new File(file);
528                    File[] projectDirs = sourceRootFile.listFiles();
529                    if (projectDirs != null) {
530                        for (File projectDir : projectDirs) {
531                            if (!projectDir.getCanonicalPath().equals(projectDir.getAbsolutePath())) {
532                                allowedSymlinks.add(projectDir.getAbsolutePath());
533                            }
534                        }
535                    }
536                }

So I guess this is just a matter of adjusting the usage message for -N.

from opengrok.

vladak avatar vladak commented on July 20, 2024

One example of how this works currently. Say we have the following under source root:

another/
foo/
bar -> foo
dir/
dir/one/
dir/two -> one

All of the directories (designated by / suffix) are repositories. The contents of all of the above should be indexed by default except the 'two' entry. For this, one would have to add -N /dir/two to the options.

However, even though the two is not recognized as allowedSymlinks it is indexed.

from opengrok.

vladak avatar vladak commented on July 20, 2024

This behavior is because of:

746    private boolean acceptSymlink(String absolutePath, String canonicalPath) throws IOException {
747        // Always accept local symlinks
748        if (isLocal(canonicalPath)) {
749            return true;
750        }
...

for the two symlink above it returns true thanks to line 749. This has been last changed in cset 9239606 ( authored by @kahatlen ) with fix for #159.

from opengrok.

vladak avatar vladak commented on July 20, 2024

isLocal() returns true because of line 787 below:

771    private boolean isLocal(String path) {
772        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
773        String srcRoot = env.getSourceRootPath();
774
775        boolean local = false;
776
777        if (path.startsWith(srcRoot)) {
778            if (env.hasProjects()) {
779                String relPath = path.substring(srcRoot.length());
780                if (project.equals(Project.getProject(relPath))) {
781                    // File is under the current project, so it's local.
782                    local = true;
783                }
784            } else {
785                // File is under source root, and we don't have projects, so
786                // consider it local.
787                local = true;
788            }
789        }
790
791        return local;
792    }

This is because path is /var/opengrok/src/dir/one (which is the canonical path for var/opengrok/src/dir/two starts with srcRoot (which is /var/opengrok/src-symlinks).

from opengrok.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.