ColdFusion Hardlink vs SoftLink traversal searching for Application.cfc (Solaris) - web

Using the following directory structure on a Solaris 11.3 box running ColdFusion 11. Apache is configured to follow Symbolic links. I have tried using all the following ColdFusion configuration options ( Default order, Until webroot, In webroot). The test2.cfm wont grab the #DATASOURCE# from the Application.cfm and so it is undefined.
/webroot
- Application.cfm
/dir1
/dir2
/dir3
-test1.cfm
/dir4 (softlink to random directory)
-test2.cfm
---------Application.cfm-------------
<CFSET DATASOURCE = "bob" >
<CFAPPLICATION NAME = "bob_app" SESSIONMANAGEMENT = "YES" >
<CFSET SESSION.USERID = "0" >
---------test1/test2.cfm-------------
<cfoutput>
The data source name is #DATASOURCE#
</cfoutput>
Any Suggestions on how to properly add the symbolic link so that search path includes the Application.cfm in the linked directory parent.

I suspect the traversal is getting messed up in the upward recursion because the directory operations are scanning upward from the absolute path of the symlinked directory - which is why symlinks aren't a good pattern for anything traversing up.
I would suggest not using symlinks for any directories which are extensions of the main application - other than static assets.
Alternately, though it's messy and less than ideal, you could just add an Application.cfm to those directories and add <cfinclude template="/Application.cfm"/> ( or include "/Application.cfm"; ) in a <cfscript> block to the beginning of the file.

Related

Linux Command to Convert an Absolute Path to a Current Existing Relative Path

I already have the relative path: /home/Folder1/Folder2 which its original absolute path is /home/user1/Folder1/Folder2. And I have several scripts that are using /home/Folder1/Folder2. Now, I need to delete user1 so I created user2 with the same structure of user1 so now I have a new path which is /home/user2/Folder1/Folder2. If I delete user1, my scripts will then fail because they are using the relative path /home/Folder1/Folder2 which its original absolute path is /home/user1/Folder1/Folder2. So I want my new path /home/user2/Folder1/Folder2 to point to /home/Folder1/Folder2 so that my scripts won't fail and I don't want to go through the trouble of opening each script and change the relative path to my new created path. Any idea how I can do this?
I guess, you got confused between soft links and absolute/relative path.
I assume you have a soft link created from "/home/Folder1/Folder2" pointing to "/home/user1/Folder1/Folder2" and you want to delete user1 directory and create user2 directory with same structure. If my assumption is right, recreate the softlink "/home/Folder1/Folder2" to point to "/home/user2/Folder1/Folder2". Your existing scripts will work seamlessly.

Win10: ASDF can't load system (ASDF_OUTPUT_TRANSLATION error)

Update 2
I think #faré is right, it's an output translation problem.
So I declared the evironment variable ASDF_OUTPUT_TRANSLATIONS and set it to E:/. Now (asdf:require-system "my-system") yields a different error: Uneven number of components in source to destination mapping: "E:/" which led me to this SO-topic.
Unfortunately, his solution doesn't work for me. So I tried the other answer and set ASDF_OUTPUT_TRANSLATIONS to (:output-translations (t "E:/")). Now I get yet another error:
Invalid source registry (:OUTPUT-TRANSLATIONS (T "E:/")).
One and only one of
:INHERIT-CONFIGURATION or
:IGNORE-INHERITED-CONFIGURATION
is required.
(will be skipped)
Original Posting
I have a simple system definition but can't get ASDF to load it.
(asdf-version 3.1.5, sbcl 1.3.12 (upgraded to 1.3.18 AMD64), slime 2.19, Windows 10)
What I have tried so far
Following the ASDF manual: "4.1 Configuring ASDF to find your systems"
There it says:
For Windows users, and starting with ASDF 3.1.5, start from your
%LOCALAPPDATA%, which is usually ~/AppData/Local/ (but you can ask in
a CMD.EXE terminal echo %LOCALAPPDATA% to make sure) and underneath
create a subpath config/common-lisp/source-registry.conf.d/
That's exactly what I did:
Echoing %LOCALAPPDATA% which evaluates to C:\Users\my-username\AppData\Local
Underneath I created the subfolders config\common-lisp\source-registry.conf.d\ (In total: C:\Users\my-username\AppData\Local\config\common-lisp\source-registry.conf.d\
The manual continues:
there create a file with any name of your choice but with the type conf, for instance 50-luser-lisp.conf; in this file, add the following line to tell ASDF to recursively scan all the subdirectories under /home/luser/lisp/ for .asd files: (:tree "/home/luser/lisp/")
That’s enough. You may replace /home/luser/lisp/ by wherever you want to install your source code.
In the source-registry.conf.d folder I created the file my.conf and put in it (:tree "C:/Users/my-username/my-systems/"). This folder contains a my-system.asd.
And here comes the weird part:
If I now type (asdf:require-system "my-system") in the REPL I get the following error:
Can't create directory C:\Users\my-username\AppData\Local\common-lisp\sbcl-1.3.12-win-x86\C\Users\my-username\my-systems\C:\
So the problem is not that ASDF doesn't find the file, it does -- but (whatever the reason) it tries to create a really weird subfolder hierarchy which ultimately fails because at the end it tries to create the folder C: but Windows doesn't allow foldernames containing a colon.
Another approach: (push path asdf:*central-registry*)
If I try
> (push #P"C:/Users/my-username/my-systems/" asdf:*central-registry*)
(#P"C:/Users/my-username/my-systems/"
#P"C:/Users/my-username/AppData/Roaming/quicklisp/quicklisp/")
> (asdf:require-system "my-system")
I get the exact same error.
I don't know what to do.
Update
Because of the nature of the weird path ASDF was trying to create I thought maybe I could bypass the problem by specifying a relative path instead of an absolute one.
So I tried
  (:tree "\\Users\\my-username\\my-systems")
in my conf file. Still the same error.
Ahem. It looks like an output-translations problem.
I don't have a Windows machine right now, but this all used to work last time I tried.
Can you setup some ad hoc output-translations for now that will make it work?

Copying folder except for one subfolder in Yeoman

I am working on this Yeoman project, and I am copying some files from a template to my new app directory.
This line is doing the job well:
this.fs.copyTpl(this.templatePath(''),
this.destinationPath(this.project_name_slugified+'/'));
Everything comes from the template folder and goes to the root folder of the project.
But when someone adds a flag '--nr' I want to exclude one subfolder that has been copied. So yo my-gen my_app_name --rf should copy EVERYTHING unless this subfolder.
I tried the !-glob notation, but it's not working. I did something like as first parameter:
[this.templatePath('**'),this.templatePath('!subfolder/subfolder_to_be_excluded')]
So second parameter was set to exclude the subfolder that is not necessary
I also tried deleting (delete method), but it seems that the file is not available immediately.
It's not working anyway. Any ideas? Promisifying the copyTpl would work?
By calling this.templatePath('!subfolder/subfolder_to_be_excluded'), you end up generating a broken path: /absolute/path/!subfolder/etc.
Use it without this.templatePath given you don't need the absolute path to apply the filtering.
this.fs.copyTpl(
[
this.templatePath('**'),
'!subfolder/subfolder_to_be_excluded'
],
this.destinationPath(this.project_name_slugified + '/'),
templateContext
);

Can't get CtrlP to set working dir as root folder

Im working on project that is in fact composed of several subproject, under a common git repository:
Project
- Sub Project A
- Sub Project B
- ...
I never work on the main folder, and always start from one of the sub projects, the problem is no matter what I try CtrlP always does the search starting from the main folder where the repo is.
I've tried a few settings from the project repo but no matter, such as bellow, but still can't get it to make any effect.
let g:ctrlp_working_path_mode = 'ca'
Any tips please?
Looking at the CtrlP docs suggests that you have three options:
Disable CtrlP's working directory searching: let g:ctrlp_working_path_mode = ''. It will then only search under Vim's current working directory, so just :cd to one of your sub projects' directories.
Ignore the sub project directories that you are not interested in: let g:ctrlp_custom_ignore = { 'dir': '\v[\/]Sub Project [AB]$' } (untested).
Add Sub Project A, Sub Project B, etc. as root markers: let g:ctrlp_root_markers = ['Sub Project A', 'Sub Project B']. This should stop CtrlP from traversing up beyond those sub directories.
I would suggest the first option since the others are a bit too hacky for my taste. The last option also didn't work for me in a quick test.
If you're used to CtrlP starting in your current working directory, and it suddenly seems to have stopped, it's probably a side effect of g:ctrlp_working_path_mode that is a bit unintuitive: it searches up the directory tree until it finds a source control root (like a .git folder), and treats that as the top level directory.
I'm used to it always being the top level of my current project, so when I started a new project, and it was using my home directory as the root, I was confused. It's because I hadn't yet initialized Git for the new project, so the first .git directory it found was in my home directory.
Initializing a Git repo for the new project made it behave as expected.
Here's the relevant section of the plugin help:
'g:ctrlp_working_path_mode'
When starting up, CtrlP sets its local working directory according to this
variable:
let g:ctrlp_working_path_mode = 'ra'
c - the directory of the current file.
a - like "c", but only applies when the current working directory outside of
CtrlP isn't a direct ancestor of the directory of the current file.
r - the nearest ancestor that contains one of these directories or files:
.git .hg .svn .bzr _darcs
w - begin finding a root from the current working directory outside of CtrlP
instead of from the directory of the current file (default). Only applies
when "r" is also present.
0 or <empty> - disable this feature.
Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as
a fallback) when a root can't be found.
Note #2: you can use a b:var to set this option on a per buffer basis.

Sourcing Puppet files from outside of modules

I'm installing a package from a module (Nginx in this specific case) and would like to include a configuration file from outside of the module, i.e. from a top level files directory parallel to the top level manifests directory. I don't see any way to source the file though without including it in a module or in my current Vagrant environment referring to the absolute local path.
Does Puppet allow for sourcing files from outside of modules as described in the documentation?
if I understand your question correctly, you can.
In your module a simple code like this
file { '/path/to/file':
ensure => present,
source => [
"puppet:///files/${fqdn}/path/to/file",
"puppet:///files/${hostgroup}/path/to/file",
"puppet:///files/${domain}/path/to/file",
"puppet:///files/global/path/to/file",
],
}
will do the job. The /path/to/file will be sourced using a file located in the "files" Puppet share.
(in the example above, it search in 4 different locations).
update maybe you're talking about a directory to store files which is not shared by Puppet fileserver (look at http://docs.puppetlabs.com/guides/file_serving.html), and in this case you can't i think, Vagrant or not, but you can add it to your Puppet fileserver to do it. I thinks it's the best (and maybe only) way to do it.
If you have a number of Vagrant VMs you can simply store files within your Vagrant project directory (containing your VagrantFile).
This directory is usually available to all VMs as /vagrant within the VM on creation.
If you want other directories on your computer to be available to your VMs just add the following to your VagrantFile
# see http://docs.vagrantup.com/v1/docs/config/vm/share_folder.html
config.vm.share_folder "v-packages", "/vagrant_packages", "../../dpkg"
Then to use the files within puppet you can simply treat them as local files to the VM
# bad example, bub basically use 'source => 'file:///vagrant/foo/bar'
file { '/opt/cassandra':
ensure => directory,
replace => true,
purge => true,
recurse => true,
source => 'file:///vagrant/conf/dist/apache-cassandra-1.2.0',
}
This is probably only wise to do if you only using local puppet manifests/modules.
Probably too late to help bennylope, but for others who happen across this question, as I did before figuring it out for myself ...
Include stuff like this in your Vagrantfile ...
GUEST_PROVISIONER_CONFDIR = "/example/destination/path"
HOST_PROVISIONER_CONFDIR = "/example/source/path"
config.vm.synced_folder HOST_PROVISIONER_CONFIDIR, GUEST_PROVISIONER_CONFDIR
puppet.options = "--fileserverconfig='#{GUEST_PROVISIONER_CONFDIR}/fileserver.conf'"
Then make sure /example/source/path contains the referenced fileserver.conf file. It should look something like ...
[foo]
path /example/destination/path
allow *
Now, assuming example-file.txt exists in /example/source/path, the following will work in your manifests:
source => "puppet:///foo/example-file.txt",
See:
Puppet configuration reference entry for fileserverconfig
Serving Files From Custom Mount Points

Resources