Changing permission to dir.

Discussion in 'DD-WRT Firmware' started by XCOM7, Jun 5, 2005.

  1. XCOM7

    XCOM7 Network Guru Member

    Ok I want to change permission to some dir in DD-WRT but is not letting me not even in shell. I get permission denied read only dir.
    Any ideas?
  2. davidsonf

    davidsonf Network Guru Member

    Download the source code, change the permissions that the binary is built with, rebuild the binary, and flash it.

    Once it is built, the read-only parts are just exactly that,
    read only.
  3. XCOM7

    XCOM7 Network Guru Member

    Thanks a lot! :)
  4. davidsonf

    davidsonf Network Guru Member

    Heh heh. :)

    But actually it doesn't make a lot of difference. The only user is root, so permissions aren't really accomplishing much to begin with, and changing them won't change that.
  5. XCOM7

    XCOM7 Network Guru Member

    Well I need to drop file in surten dir that are read only so if these is my only solution than will give it a try.
  6. davidsonf

    davidsonf Network Guru Member

    Can't be done without recompiling.

    The /tmp directory is a writable filesystem, and on those distributions that have a jffs filesystem, that is too. The jffs filesystem in based on the nvram, so it will be there after a reboot. The /tmp directory is essentially a RAM disk, and won't survive a reboot. But, there is a way to get around that! The .rc_startup file is the typical way to create a "permanent" file in /tmp that can also be edited, and the same technique can be used to create others.

    First, for a file to show up somewhere else (for example, files like /etc/host, /etc/resolv.conf and /etc/profile can all be symbolic links to files in the /tmp filesystem) it has to be compiled into the binary with those files as symlinks to something in /tmp.

    Otherwise, files like /tmp/.profile and /tmp/.rc_startup that are used directly from the /tmp filesystem can just be added regardless of which binary is being used.

    Two good examples to use are /tmp/.profile and /etc/hosts.

    To save the existing /tmp/.rc_startup file to nvram, use
               nvram set rc_startup="$(cat /tmp/.rc_startup)"
               nvram commit
    To restore whatever is in nvram to the file in /tmp, use
               nvram get rc_startup > /tmp/.rc_startup
    But... that can be done with other files, even though the system does not already have a variable in nvram dedicated to them. Hence, if /etc/hosts file is a symlink to /tmp/hosts, vi can be used to edit /tmp/hosts and add some useful host names, and then it has to be saved to nvram with a command similar to the above and set up with a command in the .rc_startup file to write it to /tmp/hosts every time the system is booted. Bingo, there is always an /etc/hosts file that is useful and survives a reboot.

    The same is true of /tmp/.profile, used as an init file for the shell. For example, here are some handy things that I have in /tmp/.profile

    store_files () {
       /usr/sbin/nvram get profile       > /tmp/.profile
       /usr/sbin/nvram get hosts         > /tmp/hosts
       /usr/sbin/nvram get resolv        > /tmp/resolv.conf
       /usr/sbin/nvram get routes        > /tmp/routes
       /usr/sbin/nvram get rc_startup > /tmp/.rc_startup
    save_files () {
      /usr/sbin/nvram set    profile="$(cat /tmp/.profile)"
      /usr/sbin/nvram set      hosts="$(cat /tmp/hosts)"
      /usr/sbin/nvram set     resolv="$(cat /tmp/resolv.conf)"
      /usr/sbin/nvram set     routes="$(cat /tmp/routes)"
      /usr/sbin/nvram set rc_startup="$(cat /tmp/.rc_startup)"
      /usr/sbin/nvram commit
    export PS1='\[\033[36m\]\h:\u \w >\[\033[m\]'
    export TZ=AKST9AKDT
    alias ll='/bin/ls -alF'
    alias ls='/bin/ls -axF'
    alias ntp='ntpclient -lsh'
    alias help='wl -h 2>&1 |more'
    if [ "1969" = $(date +%Y) ] ; then
      echo "Setting date...  [takes several seconds]"
      if ! ntpclient -h -l -s ; then
        ntpclient -h -l -s &
    So after creating /tmp/.profile, I used this command to save it all to nvram,
               nvram set profile="$(cat /tmp/.profile)"
               nvram commit
    And in the /tmp/.rc_startup file is this command,

               nvram get profile > /tmp/.profile
    As can be seen from my /tmp/.profile, there are other files saved to nvram too. (Actually, I started doing all of that using Satori firmware, and make a bit less use of it now because I'm compiling DD-WRT and Alchemy
    with my own customized additions.)
  7. XCOM7

    XCOM7 Network Guru Member

    cool thanks for the tips!
    one more question can I edit the ipkg.confg?
    I want to add a line so when I do ipkg update it will update from different servers.

    I am going to install SIPath and I am trying to install it in jffs and they recomend you add there link to the ipkg update.
  8. davidsonf

    davidsonf Network Guru Member

    I've never looked at it, so I really don't know. But if it is installed on a jffs filesystem, it is read/write, so you can edit it.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice