Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 9th September 2010, 12:04
zabersoft zabersoft is offline
Member
 
Join Date: Aug 2010
Posts: 33
Thanks: 1
Thanked 2 Times in 1 Post
Default SVN sites_web_domain_add - system_group is always "client0"

Hi,

Updated to the latest SVN to solve the problem of not knowing what the newly created domain id was for the system_user, doc_root etc. params.

Everything seems to work fine - except now the system_group value is wrong. This is the only value of the "advanced" values which is known to you before you call sites_web_domain_add - so I set it explicitly like so:

PHP Code:
$system_group 'client'.$client_id;

        
$params = array(        'server_id' => 1,
                            
'ip_address' => '*',
                            
'domain' => $input_domain,
                            
'type' => 'vhost',
                            
'parent_domain_id' =>'',
                            
'vhost_type' =>'name',
                            
'hd_quota' =>'-1',
                            
'traffic_quota' => '-1',
                            
'cgi' =>'n',
                            
'ssi' =>'n',
                            
'suexec' =>'n',
                            
'errordocs' =>'1',
                            
'subdomain' =>'www',
                            
'ssl' =>'n',
                            
'php' =>'mod',
                            
'active' => 'y',
                            
'redirect_type' =>'',
                            
'redirect_path' =>'',
                            
'ssl_state' =>'',
                            
'ssl_locality' =>'',
                            
'ssl_organisation' =>'',
                            
'ssl_organisation_unit' =>'',
                            
'ssl_country' =>'',
                            
'ssl_domain' =>'',
                            
'ssl_request' =>'',
                            
'ssl_cert' =>'',
                            
'ssl_bundle' =>'',
                            
'ssl_action' =>'',
                            
'stats_password' =>'',//!
                            //everything below ignored as we are not SOAP admin user
                            
'document_root' => 'a'// - "a" is just aplaceholder to avoid empty var errors!
                            
'system_user' =>'a',//Should be updated by ISPCP later!
                            
'system_group' =>$system_group,
                            
                            
'allow_override' =>'All',
                            
'php_open_basedir' => 'a',//!
                            
'apache_directives' =>''
                    
); 
But ISPConfig always sets system_group to client0 - Here's my server.sh output after an insert:

Code:
09.09.2010-11:58 - DEBUG - Set Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
09.09.2010-11:58 - DEBUG - Found 4 changes, starting update process.
09.09.2010-11:58 - DEBUG - Processed datalog_id 1123
09.09.2010-11:58 - DEBUG - Processed datalog_id 1124
09.09.2010-11:58 - DEBUG - Call function 'ssl' in plugin 'apache2_plugin' raised by event 'web_domain_insert'.
09.09.2010-11:58 - DEBUG - Call function 'insert' in plugin 'apache2_plugin' raised by event 'web_domain_insert'.
09.09.2010-11:58 - DEBUG - Creating Symlink: ln -s /var/log/ispconfig/httpd/testerdomain.dk /var/www/clients/client0/web204/log
09.09.2010-11:58 - DEBUG - Creating Symlink: ln -s /var/www/clients/client0/web204/ /var/www/testerdomain.dk
ln: creating symbolic link `/var/www/clients/client104/testerdomain.dk': No such file or directory
09.09.2010-11:58 - DEBUG - Creating Symlink: ln -s /var/www/clients/client0/web204/ /var/www/clients/client104/testerdomain.dk
09.09.2010-11:58 - DEBUG - Adding the user: web204
09.09.2010-11:58 - DEBUG - exec: chown -R web204:client0 /var/www/clients/client0/web204
09.09.2010-11:58 - DEBUG - exec: chown web204:client0 /var/www/clients/client0/web204
09.09.2010-11:58 - DEBUG - exec: chmod 751 /var/www/clients/client0/web204/
09.09.2010-11:58 - DEBUG - exec: chmod 751 /var/www/clients/client0/web204/*
09.09.2010-11:58 - DEBUG - exec: chmod 710 /var/www/clients/client0/web204/web
09.09.2010-11:58 - DEBUG - exec: chmod 777 /var/www/clients/client0/web204/tmp
09.09.2010-11:58 - DEBUG - exec: usermod --groups sshusers web204
09.09.2010-11:58 - DEBUG - exec: chown web204:client0 /var/www/clients/client0/web204
09.09.2010-11:58 - DEBUG - exec: chown web204:client0 /var/www/clients/client0/web204/log/error.log
09.09.2010-11:58 - DEBUG - Disable SSL for:
09.09.2010-11:58 - DEBUG - Add server alias: testerdomain.psst-psst.dk
09.09.2010-11:58 - DEBUG - Writing the vhost file: /etc/apache2/sites-available/testerdomain.dk.vhost
09.09.2010-11:58 - DEBUG - Creating the symlink: /etc/apache2/sites-enabled/testerdomain.dk.vhost => /etc/apache2/sites-available/testerdomain.dk.vhost
09.09.2010-11:58 - DEBUG - Apache status is: 1
09.09.2010-11:58 - DEBUG - Call function 'restartHttpd' in module 'web_module'.
09.09.2010-11:58 - DEBUG - Apache online status after restart is: 1
09.09.2010-11:58 - DEBUG - Processed datalog_id 1125
09.09.2010-11:58 - DEBUG - Call function 'ssl' in plugin 'apache2_plugin' raised by event 'web_domain_insert'.
09.09.2010-11:58 - DEBUG - Call function 'insert' in plugin 'apache2_plugin' raised by event 'web_domain_insert'.
ln: creating symbolic link `/var/www/clients/client104/testerdomain.dk': No such file or directory
09.09.2010-11:58 - DEBUG - Creating Symlink: ln -s /var/www/clients/client0/web204/ /var/www/clients/client104/testerdomain.dk
09.09.2010-11:58 - DEBUG - exec: chmod 751 /var/www/clients/client0/web204/
09.09.2010-11:58 - DEBUG - exec: chmod 751 /var/www/clients/client0/web204/*
09.09.2010-11:58 - DEBUG - exec: chmod 710 /var/www/clients/client0/web204/web
09.09.2010-11:58 - DEBUG - exec: chmod 777 /var/www/clients/client0/web204/tmp
09.09.2010-11:58 - DEBUG - exec: usermod --groups sshusers web204
09.09.2010-11:58 - DEBUG - exec: chown web204:client0 /var/www/clients/client0/web204
09.09.2010-11:58 - DEBUG - exec: chown web204:client0 /var/www/clients/client0/web204/log/error.log
09.09.2010-11:58 - DEBUG - Disable SSL for:
09.09.2010-11:58 - DEBUG - Add server alias: testerdomain.psst-psst.dk
09.09.2010-11:58 - DEBUG - Writing the vhost file: /etc/apache2/sites-available/testerdomain.dk.vhost
09.09.2010-11:58 - DEBUG - Apache status is: 1
09.09.2010-11:58 - DEBUG - Call function 'restartHttpd' in module 'web_module'.
09.09.2010-11:58 - DEBUG - Apache online status after restart is: 1
09.09.2010-11:58 - DEBUG - Processed datalog_id 1126
09.09.2010-11:58 - DEBUG - Remove Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
finished.
If you focus on the lines:

ln: creating symbolic link `/var/www/clients/client104/testerdomain.dk': No such file or directory
09.09.2010-11:58 - DEBUG - Creating Symlink: ln -s /var/www/clients/client0/web204/ /var/www/clients/client104/testerdomain.dk

Here it is clear something is going wrong. Any pointers would be welcome.
Reply With Quote
Sponsored Links
  #2  
Old 9th September 2010, 12:45
zabersoft zabersoft is offline
Member
 
Join Date: Aug 2010
Posts: 33
Thanks: 1
Thanked 2 Times in 1 Post
Default

The problem obviously lies here in the new plugin sites_web_domain_plugin.inc.php:

PHP Code:
// get the ID of the client
        
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {                    
            
$client_group_id $_SESSION["s"]["user"]["default_group"];
            
$client $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id");
            
$client_id intval($client["client_id"]);
        } else {                
            
//$client_id = intval($this->dataRecord["client_group_id"]);
            
$client $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($page_form->dataRecord["client_group_id"]));
            
$client_id intval($client["client_id"]);
        } 
Where $client_id ends up being "0" - I am not quite sure how to fix this problem as, despite having looked at nothing but ISPConf code for a few weeks, I am not that hot on the nitty gritty details - any tips would be nice

Does Julio lurk on this forum or should I try and throw him an email?
Reply With Quote
  #3  
Old 10th September 2010, 14:57
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,030
Thanks: 826
Thanked 5,381 Times in 4,228 Posts
Default

Please try to set "client_group_id" in the params array. A remoting user is basically logged in as "admin" when he performs any actions and as the website forms in the admin user view have a client selector (which is basically the list of groups from sys_group), you will have to provide the groupid in the params array.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #4  
Old 16th September 2010, 13:07
zabersoft zabersoft is offline
Member
 
Join Date: Aug 2010
Posts: 33
Thanks: 1
Thanked 2 Times in 1 Post
Default Fair enough... But ...

Hi Till

I didn't get back to work on the system before today, hence the lateness in my reply.

Your suggestion sounded perfectly sound and logical - but after having tried it out, I am still seeing the same issue. Do I maybe need to define client_group_id in web_domain.tform.php before it gets passed through?

I added client_group_id to my params array like so:

PHP Code:
        $params = array(        'server_id' => 1,
                            
'ip_address' => '*',
                            
'domain' => $input_domain,
                            
'type' => 'vhost',
                            
'parent_domain_id' =>'',
                            
'vhost_type' =>'name',
                            
'hd_quota' =>'-1',
                            
'traffic_quota' => '-1',
                            
'cgi' =>'n',
                            
'ssi' =>'n',
                            
'suexec' =>'n',
                            
'errordocs' =>'1',
                            
'subdomain' =>'www',
                            
'ssl' =>'n',
                            
'php' =>'mod',
                            
'active' => 'y',
                            
'redirect_type' =>'',
                            
'redirect_path' =>'',
                            
'ssl_state' =>'',
                            
'ssl_locality' =>'',
                            
'ssl_organisation' =>'',
                            
'ssl_organisation_unit' =>'',
                            
'ssl_country' =>'',
                            
'ssl_domain' =>'',
                            
'ssl_request' =>'',
                            
'ssl_cert' =>'',
                            
'ssl_bundle' =>'',
                            
'ssl_action' =>'',
                            
'stats_password' =>'',//!
                            
'document_root' => 'a'// - "a" is just aplaceholder to avoid empty var errors!
                            
'system_user' =>'a',//Should be updated by ISPCP later!
                            
'system_group' =>$system_group,
                            
                            
'allow_override' =>'All',
                            
'php_open_basedir' => 'a',//!
                            
'apache_directives' =>'',
                            
                            
'client_group_id' =>$client_id
                            
                    
); 
Reply With Quote
  #5  
Old 16th September 2010, 13:20
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,030
Thanks: 826
Thanked 5,381 Times in 4,228 Posts
Default

Quote:
Do I maybe need to define client_group_id in web_domain.tform.php before it gets passed through?
No, it is handled by the event functions directly and not the default form handler. I think we will have to debug this. You might want to make a bugreport in the bugtracker and it will get checkd until the 3.0.3 final release.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #6  
Old 16th September 2010, 13:31
zabersoft zabersoft is offline
Member
 
Join Date: Aug 2010
Posts: 33
Thanks: 1
Thanked 2 Times in 1 Post
Default this is what happens

Ok - so setting client_group_id is actually working - it just seems that the ID's are a bit wonky with me here .... And I can't quite figure it out. If we step through the plugin code then this is what happens:

First this runs, as we are admin:

PHP Code:
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) {
            
$client_group_id intval($page_form->dataRecord["client_group_id"]);
            
$app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$page_form->id);
        } 
This updates the web_domain table just fine, with the client_group_id that I pass to sites_web_domain_add - In my case that was the client_id I get back from client_add which was "112"

Then further down, we have this piece of code:

PHP Code:
        } else {                
            
$client $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($page_form->dataRecord["client_group_id"]));
            
$client_id intval($client["client_id"]);
        } 
As you can see, it is doing a lookup in sys_group to determine the client id (again) which I just passed through to the function. As the table looks like so:

groupid name description client_id
...
...
72 testerdomain.dk 112

It is clear that what you want me to pass is the system group id to client_group_id and not the actual client_id. Now we are back to the chicken and the egg problem which the plugin was supposed to fix, as I do not know the group id at this point.

So what I need to do first is call a method which returns the system user / group id?

All I see in remoting.inc.php is public function client_get_id($session_id, $sys_userid)

Which seems to take the sys id I want returned and return the client id (which I already know)

My hack would be to do an independent mysql query and fetch the group id - but I'd like to avoid that if possible.


?
Reply With Quote
  #7  
Old 17th September 2010, 13:50
zabersoft zabersoft is offline
Member
 
Join Date: Aug 2010
Posts: 33
Thanks: 1
Thanked 2 Times in 1 Post
Default

Any news on this? Is this a bug that I should add to the bugtracker or is there a more "correct" way of getting the group id?
Reply With Quote
  #8  
Old 25th September 2010, 03:34
wouterdutoit wouterdutoit is offline
Junior Member
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

lo, I also discovered this issue, which is holding me back slightly in our implementation.

zabersoft, have you logged this as a bug yet?

Ta for all the investigation work upto this point too!
Reply With Quote
  #9  
Old 27th September 2010, 10:05
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,030
Thanks: 826
Thanked 5,381 Times in 4,228 Posts
Default

Quote:
Then further down, we have this piece of code:
But as you see it is in the else part of the query, so it does not get executed when you are llogged in as admin user and the remoting framework has admin user status.

Quote:
So what I need to do first is call a method which returns the system user / group id?

All I see in remoting.inc.php is public function client_get_id($session_id, $sys_userid)

Which seems to take the sys id I want returned and return the client id (which I already know)
The remoting framework works with the client_id and not the sys_userid. The sys_userid and sys_groupid is only for internal use in ispconfig and may change or may be different even for the same client. So dont rely on that, use the client_id instead. The sys_userid of the records is always set by the remoting framework automatically, so do not pass it in the params array as it get oiverwritten anyway.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #10  
Old 29th September 2010, 21:37
zabersoft zabersoft is offline
Member
 
Join Date: Aug 2010
Posts: 33
Thanks: 1
Thanked 2 Times in 1 Post
 
Default

Hi Till,

No, you are almost correct but not quite - the else statement you see above is not in connection with the first part of code - it is further down in the plugin code - the entire statement is like so:

PHP Code:
        // get the ID of the client
        
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            
$client_group_id $_SESSION["s"]["user"]["default_group"];
            
$client $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id");
            
$client_id intval($client["client_id"]);
        } else {
            
//$client_id = intval($this->dataRecord["client_group_id"]);
            
$client $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($page_form->dataRecord["client_group_id"]));
            
$client_id intval($client["client_id"]);
        } 
I see this as IF NOT admin DO stuff else DO wrong stuff I am complaining about

I have tested this - if fetch the groupid manually from the db and then pass the groupid as client_id - everything works as it should

And as you say yourself - this should not be happening. So I maintain that the code is buggy.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailuser interface Horfic Plugins/Modules/Addons 497 28th November 2013 10:01
SVN Access Control List Error PavementPounder Server Operation 0 8th February 2009 05:23
SVN Access Control List Error PavementPounder Server Operation 0 8th February 2009 05:23
[ADVANCED] - Browsing the SVN Server files using ISPConfig vaio1 Installation/Configuration 5 1st July 2008 21:57
SVN (subversion) gonna kill me! ru4r34l HOWTO-Related Questions 4 19th June 2008 04:07


All times are GMT +2. The time now is 18:00.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.