Uploaded image for project: 'OpenVZ'
  1. OpenVZ
  2. OVZ-4491

vzctl - vps_save_config will overwrite a CTs config if it is a symlink

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Fix Version/s: OpenVZ-legacy
    • Component/s: Containers::Userspace
    • Security Level: Public
    • Environment:
      Operating System: All
      Platform: All

      Description

      A symlink to a CTs config is overwritten by vps_save_config() on writeback, this is because a symlink to the config is not dereferenced

      The first (very simple) fix:

      --- a/src/lib/config.c 2009-11-04 08:39:18.000000000 +0100
      +++ b/src/lib/config.c 2009-11-04 08:39:18.000000000 +0100
      @@ -2351,6 +2351,8 @@
              vps_param *tmp_old_p = NULL;
              list_head_t conf, new_conf;
              int ret, n;
      + char buf[4096];
      + ssize_t llen;

              list_head_init(&conf);
              list_head_init(&new_conf);
      @@ -2359,6 +2361,13 @@
                      vps_parse_config(veid, path, tmp_old_p, action);
                      old_p = tmp_old_p;
              }
      +
      + /* if path is a symlink dereference it */
      + if ((llen = readlink(path, buf, sizeof(buf)-1)) != -1) {
      + buf[llen] = '\0';
      + strcpy(path,buf);
      + }
      +
              if ((ret = read_conf(path, &conf)))
                      return ret;
              n = store(old_p, new_p, &new_conf);

      But as ldv suggested it makes more sense to use canonicalize_file_name()

      The following snip is not working for me ... not sure why?
        -> implicit declaration of function 'canonicalize_file_name'


      static int write_conf(char *fname, list_head_t *head)
        ...
        file = canonicalize_file_name(fname);
        ...

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              igor Igor Sukhih
              Reporter:
              flipstar@gmx.net flipstar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: