Re: links vs real directories

2009-03-16 Thread Wojciech Puchar

drwxr-xr-x  4 master  master   512 Mar 16 11:06 db
etc...


So, I guess a link is NOT exactly equivalent to a directory. At least not the 
way I am doing it.


I'm guessing I'm making a real newbie mistake, so if anyone can set me 
straight, I'd appreciate it.


IMHO you did everything properly, this program must actually check if it's 
link.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: links vs real directories

2009-03-16 Thread Bill Moran
In response to John Almberg :
> 
> A little more information on this... from the Rails log, I can see  
> that a Ruby script in the config directory cannot load ('require') a  
> needed file because it can't find it:
> 
> /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in  
> `gem_original_require': no such file to load -- application  
> (MissingSource File)
> 
> It looks like this require statement is using a relative path, like  
> '../path/to/file'. Does '..' not work properly with a soft link? In  
> other words, '..', should mean ~/app, but since the config directory  
> is really in '~/shared', perhaps '..' translates to '~/shared'? That  
> would cause the problem finding the file.

That's a common problem with soft links and interpreted languages.

> Is there a way around this problem?

Generally, you have to fix this in the application itself.  I'm not a
Ruby expert, but I can list some of the methods that solve the problem
in PHP:

1 If Ruby has a config value for including library files (often called a
  "search path"), configure it  to the correct paths and tell Ruby to
  include the file name with the configured path information.
2 Write a wrapper around the requirement function that normalizes the path
  so that it works.
3 Ditch the softlink altogether and require files by absolute path.

The first one is probably the most desirable, although I've had good
success using PHP's __autoload() to accomplish #2.  Don't know if there's
an equivalent in Ruby.

In any event, if you're explicitly including files by relative path, you'll
have to stop doing that.  It's a bad idea in any event.

-- 
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: links vs real directories

2009-03-16 Thread Chris Rees
2009/3/16 John Almberg :
>
> On Mar 16, 2009, at 11:39 AM, Erik Trulsson wrote:
>
>> On Mon, Mar 16, 2009 at 11:22:13AM -0400, John Almberg wrote:
>>>
>>> I always thought that links to real directories were pretty much the
>>> same as real directories, but I've just discovered a situation where
>>> they are not and I'm wondering if I'm doing something wrong...
>>
>> A *soft* link to a directory entry (be it a directory or a file or
>> something
>> else) is not quite equivalent to the original entry since they are easily
>> distinguished and some programs do treat softlinks differently from other
>> targets.
>
> I can see that, now... If I create a soft link to ~/shared/config, and then
> cd into the directory, when I type 'ls ..', I get the listing for ~/shared,
> not ~/app.
>
> Bummer...
>
> I've just dug through man ln, and don't see any obvious solution. Since this
> must be a problem for anyone who wants to do something like this, I guess I
> am taking the wrong approach, altogether.
>
> Will have to re-think this
>
> 
>
> -- John
>
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
>

When we're talking in a technical sense, we should probably use the
correct terms. The 'official' and more descriptive name for a softlink
is a symbolic link.

Symbolic links are an absolute nightmare for security purposes, and
many programs (especially ones set to run suid) choke on them. This
could be intentional

Since RoR is free software, you could dive in and edit where it looks
for in the source code, or look for a compile-time option. Try

/dir/to/port's/work/directory # ./configure --help


Chris

--
R< $&h ! > $- ! $+      $@ $2 < @ $1 .UUCP. > (sendmail.cf)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: links vs real directories

2009-03-16 Thread Erik Trulsson
On Mon, Mar 16, 2009 at 11:47:23AM -0400, John Almberg wrote:
> 
> On Mar 16, 2009, at 11:39 AM, Erik Trulsson wrote:
> 
> > On Mon, Mar 16, 2009 at 11:22:13AM -0400, John Almberg wrote:
> >> I always thought that links to real directories were pretty much the
> >> same as real directories, but I've just discovered a situation where
> >> they are not and I'm wondering if I'm doing something wrong...
> >
> > A *soft* link to a directory entry (be it a directory or a file or  
> > something
> > else) is not quite equivalent to the original entry since they are  
> > easily
> > distinguished and some programs do treat softlinks differently from  
> > other
> > targets.
> 
> I can see that, now... If I create a soft link to ~/shared/config,  
> and then cd into the directory, when I type 'ls ..', I get the  
> listing for ~/shared, not ~/app.

Yes, because '..' is a hardlink to the parent directory, and 'cd' does not
know how you got to ~/shared/config so it does not know anything about the
softlink used to get theere.


> 
> Bummer...
> 
> I've just dug through man ln, and don't see any obvious solution.  
> Since this must be a problem for anyone who wants to do something  
> like this, I guess I am taking the wrong approach, altogether.
> 
> Will have to re-think this
> 
> 
> 
> -- John
> 

-- 

Erik Trulsson
ertr1...@student.uu.se
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: links vs real directories

2009-03-16 Thread John Almberg


On Mar 16, 2009, at 11:47 AM, John Almberg wrote:



On Mar 16, 2009, at 11:39 AM, Erik Trulsson wrote:


On Mon, Mar 16, 2009 at 11:22:13AM -0400, John Almberg wrote:

I always thought that links to real directories were pretty much the
same as real directories, but I've just discovered a situation where
they are not and I'm wondering if I'm doing something wrong...


A *soft* link to a directory entry (be it a directory or a file or  
something
else) is not quite equivalent to the original entry since they are  
easily
distinguished and some programs do treat softlinks differently  
from other

targets.


I can see that, now... If I create a soft link to ~/shared/config,  
and then cd into the directory, when I type 'ls ..', I get the  
listing for ~/shared, not ~/app.


Bummer...

I've just dug through man ln, and don't see any obvious solution.  
Since this must be a problem for anyone who wants to do something  
like this, I guess I am taking the wrong approach, altogether.


Will have to re-think this




Okay! I guess I wasn't the first to have this problem...

lndir (in ports) solves the problem by creating a set of soft links  
for all the files in the 'linked' directory. Kinda kludgy, but it works.


-- John

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: links vs real directories

2009-03-16 Thread John Almberg


On Mar 16, 2009, at 11:39 AM, Erik Trulsson wrote:


On Mon, Mar 16, 2009 at 11:22:13AM -0400, John Almberg wrote:

I always thought that links to real directories were pretty much the
same as real directories, but I've just discovered a situation where
they are not and I'm wondering if I'm doing something wrong...


A *soft* link to a directory entry (be it a directory or a file or  
something
else) is not quite equivalent to the original entry since they are  
easily
distinguished and some programs do treat softlinks differently from  
other

targets.


I can see that, now... If I create a soft link to ~/shared/config,  
and then cd into the directory, when I type 'ls ..', I get the  
listing for ~/shared, not ~/app.


Bummer...

I've just dug through man ln, and don't see any obvious solution.  
Since this must be a problem for anyone who wants to do something  
like this, I guess I am taking the wrong approach, altogether.


Will have to re-think this



-- John

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: links vs real directories

2009-03-16 Thread John Almberg


On Mar 16, 2009, at 11:22 AM, John Almberg wrote:

I always thought that links to real directories were pretty much  
the same as real directories, but I've just discovered a situation  
where they are not and I'm wondering if I'm doing something wrong...


I have a Ruby on Rails application running on a FreeBSD server. All  
Rails apps use the same directory structure, that consists of an  
application directory, plus a number of subdirectories. One of  
these sub directories is called 'config'.


I would like to move this config directory out of the main Rails  
app directory, and then add a link from the app directory to the  
moved config directory.


so:

app --> config

will become

app --> config(link) --> config

Basically, what I'm doing is:

cd ~/app # now in directory with real 'config' dir
mv config ~/shared/config
ln -s ~/shared/config config

That moves the directory and creates a functional link to it (I  
tested it), but Rails doesn't like it and refuses to run the app.  
The permissions are correct, I believe:


[mas...@on:current]> ls -l
total 34
... snip ...
drwxrwxr-x  3 master  master   512 Mar 16 11:06 bin
drwxrwxr-x  3 master  master   512 Mar 16 11:06 components
lrwxr-xr-x  1 master  master26 Mar 16 11:07 config -> /home/ 
master/shared/config

drwxr-xr-x  4 master  master   512 Mar 16 11:06 db
etc...


So, I guess a link is NOT exactly equivalent to a directory. At  
least not the way I am doing it.


I'm guessing I'm making a real newbie mistake, so if anyone can set  
me straight, I'd appreciate it.


Thank: John
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions- 
unsubscr...@freebsd.org"


A little more information on this... from the Rails log, I can see  
that a Ruby script in the config directory cannot load ('require') a  
needed file because it can't find it:


/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in  
`gem_original_require': no such file to load -- application  
(MissingSource File)


It looks like this require statement is using a relative path, like  
'../path/to/file'. Does '..' not work properly with a soft link? In  
other words, '..', should mean ~/app, but since the config directory  
is really in '~/shared', perhaps '..' translates to '~/shared'? That  
would cause the problem finding the file.


Is there a way around this problem?

Digging in man ls, right now..

-- John

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: links vs real directories

2009-03-16 Thread Erik Trulsson
On Mon, Mar 16, 2009 at 11:22:13AM -0400, John Almberg wrote:
> I always thought that links to real directories were pretty much the  
> same as real directories, but I've just discovered a situation where  
> they are not and I'm wondering if I'm doing something wrong...

A *soft* link to a directory entry (be it a directory or a file or something
else) is not quite equivalent to the original entry since they are easily
distinguished and some programs do treat softlinks differently from other 
targets.

A hardlink to a file is exactly equivalent to the original (since the original
directory entry is itself a hardlink).  The system does not however allow
you to create hardlinks to directories since it is far too easy to
make Very Bad Things happen that way.


> 
> I have a Ruby on Rails application running on a FreeBSD server. All  
> Rails apps use the same directory structure, that consists of an  
> application directory, plus a number of subdirectories. One of these  
> sub directories is called 'config'.
> 
> I would like to move this config directory out of the main Rails app  
> directory, and then add a link from the app directory to the moved  
> config directory.
> 
> so:
> 
> app --> config
> 
> will become
> 
> app --> config(link) --> config
> 
> Basically, what I'm doing is:
> 
> cd ~/app # now in directory with real 'config' dir
> mv config ~/shared/config
> ln -s ~/shared/config config
> 
> That moves the directory and creates a functional link to it (I  
> tested it), but Rails doesn't like it and refuses to run the app. The  
> permissions are correct, I believe:
> 
> [mas...@on:current]> ls -l
> total 34
> ... snip ...
> drwxrwxr-x  3 master  master   512 Mar 16 11:06 bin
> drwxrwxr-x  3 master  master   512 Mar 16 11:06 components
> lrwxr-xr-x  1 master  master26 Mar 16 11:07 config -> /home/ 
> master/shared/config
> drwxr-xr-x  4 master  master   512 Mar 16 11:06 db
> etc...
> 
> 
> So, I guess a link is NOT exactly equivalent to a directory. At least  
> not the way I am doing it.
> 
> I'm guessing I'm making a real newbie mistake, so if anyone can set  
> me straight, I'd appreciate it.
> 
> Thank: John
>   

-- 

Erik Trulsson
ertr1...@student.uu.se
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


links vs real directories

2009-03-16 Thread John Almberg
I always thought that links to real directories were pretty much the  
same as real directories, but I've just discovered a situation where  
they are not and I'm wondering if I'm doing something wrong...


I have a Ruby on Rails application running on a FreeBSD server. All  
Rails apps use the same directory structure, that consists of an  
application directory, plus a number of subdirectories. One of these  
sub directories is called 'config'.


I would like to move this config directory out of the main Rails app  
directory, and then add a link from the app directory to the moved  
config directory.


so:

app --> config

will become

app --> config(link) --> config

Basically, what I'm doing is:

cd ~/app # now in directory with real 'config' dir
mv config ~/shared/config
ln -s ~/shared/config config

That moves the directory and creates a functional link to it (I  
tested it), but Rails doesn't like it and refuses to run the app. The  
permissions are correct, I believe:


[mas...@on:current]> ls -l
total 34
... snip ...
drwxrwxr-x  3 master  master   512 Mar 16 11:06 bin
drwxrwxr-x  3 master  master   512 Mar 16 11:06 components
lrwxr-xr-x  1 master  master26 Mar 16 11:07 config -> /home/ 
master/shared/config

drwxr-xr-x  4 master  master   512 Mar 16 11:06 db
etc...


So, I guess a link is NOT exactly equivalent to a directory. At least  
not the way I am doing it.


I'm guessing I'm making a real newbie mistake, so if anyone can set  
me straight, I'd appreciate it.


Thank: John
 
___

freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"