LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Disk quota for 'virtual' user (http://www.linuxquestions.org/questions/linux-server-73/disk-quota-for-virtual-user-533382/)

Bogdan 02-28-2007 05:25 PM

Disk quota for 'virtual' user
 
Hi I use proftp with virtual users stored in mysql. After user login, proftpd create files with virtual user UID, that does not exist in /etc/passwd.

When I do:
quotatool -b -l 10MB -u 10014 /home/
I get:
quotatool: User 10014 does not exist

How could It be fixed? AFAIK kernel use only numeric UID's... Why it is not possible to set quota for uid?

Brian1 02-28-2007 06:58 PM

Did a quick search for ' quota control virtual user ' on Google and the first link was this.
http://linuxcult.blogspot.com/2006/0...and-mysql.html

Also might check this out. Not sure if it will help.
http://souptonuts.sourceforge.net/quota_tutorial.html

Brian

Bogdan 03-01-2007 03:02 AM

Brian1 -
1st link is common firt-line-of-google-stuff. Proftpd support transfer quotas, no storage. And I use them now.
2nd link seems to be usefull, at least I'll have to write my own quota tool thanx ;)
I'll try to remove
Code:

  if ((pwd = getpwnam(user)) == NULL) {
          printf(stderr, "Invalid -u option \n");
          exit(1);
      }

Or so from quotatool sources.

Bogdan 03-01-2007 08:06 AM

I modify system.c in quotatool-1.4.9
Code:

uid_t system_getuid (char *user) {
  struct passwd *pwent;
  int uid;
  char *temp_str;
  /* seach by name first */
  pwent = getpwnam (user);

  if ( pwent == NULL ) {

    /* maybe we were given a numerical id */
    uid = strtol(user, &temp_str, 10);
    pwent = getpwuid ((uid_t) uid);
/*    if ( (user == temp_str) || ( pwent == NULL ) ) { */
        if ( user == temp_str ) {
      output_error ("User %s does not exist\n", user);
      return -1;
    }
    return uid;
  }
  output_info ("user '%s' has uid %d", user, pwent->pw_uid);
  return (pwent->pw_uid);
}

And now it does not check /etc/passwd if numerical uid was passed.
Seems to work for me.


All times are GMT -5. The time now is 09:19 AM.