• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

difference between /dev/urandom & file:/dev/./urandom

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have doubt in the signature of the two paths which is used as java secure file :

file:/dev/urandom
$
file:/dev/./urandom

can anybody please let me know what is the difference between them..

Thanks
Premchand
 
Saloon Keeper
Posts: 14502
325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not a Unix champion, but I believe the first one is a path to the file, while the second one executes it (and gives you a secure random number).

Nope, there is no difference. The extra "./" just means "current directory", like it does in Windows.
 
Marshal
Posts: 76881
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks like something platform‑specific which you would never see on a Windows® box.

Try putting those two into a Path object (or a java.io.File object) and call getXXX methods on them. Try for the path and the canonical path. I think you will find that the second turns into the first when you use the canonical path. What you have in the first is
  • 1: You are looking for a file on your own machine rather than elsewhere via http, ftp, etc.
  • 2: The / takes you to the very root of the file system.
  • 3: dev/ is one of the directories in the file system.
  • 4: It contains a file called urandom.
  • The difference in the second is that after dev, you are calling ./ Now . means current directory (I think it is the same on Windows®) so ./ means look in the same directory that you were in already. So you can remove the ./ and not change the meaning of the path. Or you can add ./ as often as you like (in the middle of the path String) without changing where you end up.
     
    Campbell Ritchie
    Marshal
    Posts: 76881
    366
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    They are both the same: look. Same output for both

    campbell@campbellsComputer:someDirectory$ file:/dev/urandom
    bash: file:/dev/urandom: No such file or directory
    campbell@campbellsComputer:someDirectory$ file:/dev/./urandom
    bash: file:/dev/./urandom: No such file or directory

     
    Greenhorn
    Posts: 3
    3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    According to this post,

    you need the crazy-looking filename, e.g., the extra /./, to trick Java into accepting your filename. If you just use /dev/urandom, Java decides you didn't really mean it and replaces what you wrote with /dev/random.

     
    Campbell Ritchie
    Marshal
    Posts: 76881
    366
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Have a cow for finding that strange behaviour. Is that a Java® bug?
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 14502
    325
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    A cow from me too.
     
    Saloon Keeper
    Posts: 26294
    186
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Campbell Ritchie wrote:Have a cow for finding that strange behaviour. Is that a Java® bug?



    Offhand, I'd guess that it's more of a Linux® feature and has to do with the original purely-mathematical means of finding random numbers (as dismissed in Knuth) and the later more truly random generator device.

    In FreeBSD, urandom is softlinked to /dev/random. In my Linux machine they are distinctly different devices. Methinks the funny syntax is to portably defeat the softlink.
     
    If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic