IspConfig API: FTP & Email not accessible

Discussion in 'Developers' Forum' started by vaio1, Dec 5, 2011.

  1. vaio1

    vaio1 Member

    Hi guys,

    I am using your API to connect my software to your IspConfig these are my steps:

    1. Create a client (client_add)
    2. Create the website (sites_web_domain_add)
    3. Create the FTP account (sites_ftp_user_add)
    4. Create the Email Account (mail_user_add)
    5. Create the Database (sites_database_add)

    All the elements are visible in the IspConfig panel but the FTP and the Email doesn't work. :confused:

    I mean that If I try to log with roundcube for the email account and/or browse by the Filezilla the ftp profile created It doesn't connect.

    These are the parameters log from my software to your software:

    Code:
    05-12-2011 09:48:32 - ID 1 - Shineisp_Api_Panels_Ispconfig_Main::create_client - Paramenters: {"company_name":"My User","contact_name":"John Doe","customer_no":"212","vat_id":"IT1231231231","email":"[email protected]","street":"via Roma 31","zip":"20111","city":"Milan","state":"TS","country":"IT","mobile":[],"fax":[],"telephone":"+39.0400644524","language":"it","usertheme":"default","template_master":0,"template_additional":"","created_at":0,"limit_web_quota":"3000","limit_mailbox":"10","limit_database":"3","limit_traffic_quota":"12000","limit_ftp_user":"3","limit_web_domain":"5","limit_mailaliasdomain":"1","limit_maildomain":"10","limit_mailcatchall":"3","limit_mailforward":"10","limit_mailrouting":"10","limit_fetchmail":"3","limit_mailfilter":"10","limit_mailquota":"1000","limit_spamfilter_wblist":"-1","limit_web_aliasdomain":"10","limit_cron_frequency":"15","limit_cron_type":"url","limit_web_subdomain":"15","limit_spamfilter_policy":"-1","ssh_chroot":"no,jailkit","limit_spamfilter_user":"-1","limit_webdav_user":"0","limit_cron":"7","limit_shell_user":"0","web_php_options":"no,fast-cgi","username":"johndoe","password":"furerufe"}
    05-12-2011 09:48:33 - ID 1 - Shineisp_Api_Panels_Ispconfig_Main::create_website - Paramenters: {"server_id":"1","ip_address":"","domain":"johndoe.com","type":"vhost","parent_domain_id":0,"vhost_type":"name","hd_quota":"3000","traffic_quota":"12000","errordocs":1,"is_subdomainwww":1,"subdomain":"www","php":"fast-cgi","active":"y","traffic_quota_lock":"n","system_user":"web1","allow_override":"All","custom_php_ini":"","apache_directives":""}
    05-12-2011 09:48:34 - ID 1 - Shineisp_Api_Panels_Ispconfig_Main::create_ftp - Paramenters: {"server_id":1,"parent_domain_id":3790,"username":"xewewajo","password":"wudoteyo","quota_size":"3000","active":"y","uid":"5000","gid":"5000","dir":"maybe","quota_files":-1,"ul_ratio":-1,"dl_ratio":-1,"ul_bandwidth":-1,"dl_bandwidth":-1}
    05-12-2011 09:48:43 - ID 1 - Shineisp_Api_Panels_Ispconfig_Main::create_mail - Paramenters: {"server_id":"3","email":"[email protected]","login":"[email protected]","password":"dedubati","uid":5000,"gid":5000,"maildir":"","quota":1048576000,"cc":"","homedir":"","autoresponder":"n","autoresponder_start_date":"","autoresponder_end_date":"","autoresponder_text":"","move_junk":"n","custom_mailfilter":"spam","postfix":"y","access":"n","disableimap":"n","disablepop3":"n","disabledeliver":"n","disablesmtp":"n"}
    05-12-2011 09:48:47 - ID 1 - Shineisp_Api_Panels_Ispconfig_Main::create_database - Paramenters: {"server_id":"2","type":"y","database_name":"db_o","database_user":"mahugima","database_password":"yuwicini","database_charset":"UTF8","remote_access":"y","remote_ips":"","active":"y"}
    
    FTP:
    Code:
    Risposta:	220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
    Risposta:	220-You are user number 1 of 50 allowed.
    Risposta:	220-Local time is now 09:56. Server port: 21.
    Risposta:	220-This is a private system - No anonymous login
    Risposta:	220-IPv6 connections are also welcome on this server.
    Risposta:	220 You will be disconnected after 15 minutes of inactivity.
    Comando:	USER xewewajo
    Risposta:	331 User xewewajo OK. Password required
    Comando:	PASS ********
    Risposta:	[B]421 Home directory not available - aborting[/B]
    
    Email
    Seems that the email has been not created. Roundcube tells me that there is not any account with the credencials posted.

    Furthermore if I delete the customer and all the services by the IspConfig panel I get this error: Possible security violation when deleting the maildir

    If you need to see my inteface for IspConfig take a look at: http://code.google.com/p/shineisp/source/browse/trunk/library/Shineisp/Api/Panels/IspConfig/Main.php
     
    Last edited: Dec 5, 2011
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Seems as if you have not set the maildir or that you set a invalid maildir path while you created. You might want to take a look at bthe example functions that we proviude in the 3.0.4.1 tar.gz and also compare the database records for mail users that you created with the api with one that you created in ispconfig to see the correct parameters.
     
  3. vaio1

    vaio1 Member

    Hi Till,

    these are my email parameters sent to ISPConfig API:

    Code:
    {
       "server_id":"3",
       "email":"[email protected]",
       "login":"[email protected]",
       "password":"dedubati",
       "uid":5000,
       "gid":5000,
       "maildir":"",
       "quota":1048576000,
       "cc":"",
       "homedir":"",
       "autoresponder":"n",
       "autoresponder_start_date":"",
       "autoresponder_end_date":"",
       "autoresponder_text":"",
       "move_junk":"n",
       "custom_mailfilter":"spam",
       "postfix":"y",
       "access":"n",
       "disableimap":"n",
       "disablepop3":"n",
       "disabledeliver":"n",
       "disablesmtp":"n"
    }
    
    and these are your parameters:

    Code:
    'server_id' => 1,
    			'email' => '[email protected]',
    			'login' => '[email protected]',
    			'password' => 'howtoforge',
    			'name' => 'hmmnoe',
    			'uid' => 5000,
    			'gid' => 5000,
    			'maildir' => '',
    			'quota' => 10000000000,
    			'cc' => '',
    			'homedir' => '',
    			'autoresponder' => 'n',
    			'autoresponder_start_date' => '',
    			'autoresponder_end_date' => '',
    			'autoresponder_text' => 'hallo',
    			'move_junk' => 'n',
    			'custom_mailfilter' => 'spam',
    			'postfix' => 'n',
    			'access' => 'n',
    			'disableimap' => 'n',
    			'disablepop3' => 'n',
    			'disabledeliver' => 'n',
    			'disablesmtp' => 'n'
    
    I don't see any difference for the maildir param. :(
     
  4. vaio1

    vaio1 Member

    I have solved the eMail maildir problem.
    In your example you have to write the default value

    Code:
    'gid' => 5000,
    [B]'maildir' => '',[/B]
    'quota' => 10000000000,
    'cc' => '',
    
    You have to tell to your "fans" that the maildir needs a parameter like:

    Code:
    'gid' => 5000,
    [B]'maildir' => '/var/vmail/yourdomain.com/info',[/B]
    'quota' => 10000000000,
    'cc' => '',
    
    Now I can login with roundcube!

    Anyway when the email is deleted by IspConfig this error appears: Possible security violation when deleting the maildir
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    The reason are your test records without maildir, as a empty maildir is a security violation for the system.
     
  6. vaio1

    vaio1 Member

    Yes now I have completely solved the email problem, thanks!

    Now I am trying to solve the ftp problem.
     
  7. vaio1

    vaio1 Member

    Nothing to do :(

    I have set the parameters as mentioned in your example but If I set the UID and the GID Filezilla doesn't connect to the profile. This is my snipped code: http://code.google.com/p/shineisp/s...ry/Shineisp/Api/Panels/IspConfig/Main.php#268

    Code:
    Risposta:	220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
    Risposta:	220-You are user number 1 of 50 allowed.
    Risposta:	220-Local time is now 12:18. Server port: 21.
    Risposta:	220-This is a private system - No anonymous login
    Risposta:	220-IPv6 connections are also welcome on this server.
    Risposta:	220 You will be disconnected after 15 minutes of inactivity.
    Comando:	USER jdoe_ftp1
    Risposta:	331 User jdoe_ftp1 OK. Password required
    Comando:	PASS ********
    Risposta:	530 Login authentication failed
    
    Updates:
    - When I set the UID and GID with the value: 5000 I can login with filezilla but I see only empty dir and not the web dir.
    - When I set the UID and GID with the correct web3798 and client133 I don't connect myself anymore.

    Why!?
     
    Last edited: Dec 5, 2011
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats the UID for the email accounts in /var/vmail, not websites. Dont use this uid for anything related to websites.

    Compare your ftp user and the website you created by the remote api with a website and FTP user that you created trough ispconfig interface to see the correct parameters for the records.
     
  9. vaio1

    vaio1 Member

    I have found a little bug in the vhost configuration:

    Code:
    /etc/apache2/sites-enabled/100-thedomain.com.vhost
    
    In the IspConfig vhost file I can see the <VirtualHost *:80> but when the API create the vhost file I get <VirtualHost :80>.

    Why?

    Furthermore when I restart the webserver I get:
    Code:
    [B]# /etc/init.d/apache2 restart[/B]
    sh: getcwd() failed: No such file or directory
    Restarting web server: apache2sh: getcwd() failed: No such file or directory
     ... waiting sh: getcwd() failed: No such file or directory
    
     
  10. vaio1

    vaio1 Member

    It's hard to debug your code or read your database without any documentation. I have followed what you are written in the samples and the FTP doesn't work.

    What have I wrong in these parameters?

    Code:
    Paramenters: {
       "server_id":1,
       "parent_domain_id":3800,
       "username":"jdoe_ftp1",
       "password":"bexujuga",
       "quota_size":"3000",
       "active":"y",
    [B]   "uid":"web135",
       "gid":"client3800",[/B]
       "dir":"\/var\/www\/clients\/client135\/web3800",
       "quota_files":-1,
       "ul_ratio":-1,
       "dl_ratio":200,
       "ul_bandwidth":-1,
       "dl_bandwidth":100
    }
    
    Web Site Parameters
    Code:
    {
       "server_id":"1",
       "ip_address":"",
       "domain":"testdomain.com",
       "type":"vhost",
       "parent_domain_id":0,
       "vhost_type":"name",
       "hd_quota":"3000",
       "traffic_quota":"12000",
       "errordocs":1,
       "is_subdomainwww":1,
       "subdomain":"www",
       "php":"fast-cgi",
       "active":"y",
       "traffic_quota_lock":"n",
       "system_user":"web1",
       "allow_override":"All",
       "custom_php_ini":"",
       "apache_directives":""
    }
    
     
    Last edited: Dec 5, 2011
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Your code is very different from the examples, e.g. you escaped that path this way "\/var\/www\/clients\/client135\/web3800" and normally a / has not to be escaped and where are all the other website parameters, the example has 39 values in the params array and you have 18.

    You should really check the examples again, they had been tested right before 3.0.4 was released and they worked at that time so I assume that they still work as the remote API as not changed from 3.0.4 to 3.0.4.1.
     
  12. vaio1

    vaio1 Member

    Hi Till,

    the path is escaped because the array that I shown you is a json encode array.

    These are your parameters for sites_ftp_user_add:
    Code:
    	$params = array(
    			'server_id' => 1,
    			'parent_domain_id' => 1,
    			'username' => 'threep',
    			'password' => 'wood',
    			'quota_size' => 10000,
    			'active' => 'y',
    			'uid' => '5000',
    			'gid' => '5000',
    			'dir' => 'maybe',
    			'quota_files' => -1,
    			'ul_ratio' => -1,
    			'dl_ratio' => -1,
    			'ul_bandwidth' => -1,
    			'dl_bandwidth' => -1
    			);
    
    and these are mine:

    Code:
    Paramenters: {
       "server_id":1,
       "parent_domain_id":3800,
       "username":"jdoe_ftp1",
       "password":"bexujuga",
       "quota_size":"3000",
       "active":"y",
       "uid":"web135",
       "gid":"client3800",
       "dir":"\/var\/www\/clients\/client135\/web3800",
       "quota_files":-1,
       "ul_ratio":-1,
       "dl_ratio":200,
       "ul_bandwidth":-1,
       "dl_bandwidth":100
    }
    
    These are your parameters for sites_web_domain_add:

    Code:
    	$params = array(
    			'server_id' => 0,
    			'ip_address' => '',
    			'domain' => 'test2.int',
    			'type' => 'vhost',
    			'parent_domain_id' => 0,
    			'vhost_type' => 'name',
    			'hd_quota' => 100000,
    			'traffic_quota' => -1,
    			'cgi' => 'y',
    			'ssi' => 'y',
    			'suexec' => 'y',
    			'errordocs' => 1,
    			'is_subdomainwww' => 1,
    			'subdomain' => '',
    			'php' => 'y',
    			'ruby' => 'n',
    			'redirect_type' => '',
    			'redirect_path' => '',
    			'ssl' => 'n',
    			'ssl_state' => '',
    			'ssl_locality' => '',
    			'ssl_organisation' => '',
    			'ssl_organisation_unit' => '',
    			'ssl_country' => '',
    			'ssl_domain' => '',
    			'ssl_request' => '',
    			'ssl_cert' => '',
    			'ssl_bundle' => '',
    			'ssl_action' => '',
    			'stats_password' => '',
    			'stats_type' => 'webalizer',
    			'allow_override' => 'All',
    			'apache_directives' => '',
    			'php_open_basedir' => '/',
    			'custom_php_ini' => '',
    			'backup_interval' => '',
    			'backup_copies' => 1,
    			'active' => 'y',
    			'traffic_quota_lock' => 'n'
    			);
    
    and these are mine:

    Code:
    Parameters: {
       "server_id":"1",
       "ip_address":"",
       "domain":"testdomain.com",
       "type":"vhost",
       "parent_domain_id":0,
       "vhost_type":"name",
       "hd_quota":"3000",
       "traffic_quota":"12000",
       "errordocs":1,
       "is_subdomainwww":1,
       "subdomain":"www",
       "php":"fast-cgi",
       "active":"y",
       "traffic_quota_lock":"n",
       "system_user":"web1",
       "allow_override":"All",
       "custom_php_ini":"",
       "apache_directives":""
    }
    
    I have sent the main and not null parameters because I think that you have check all the parameters received from a calling or not?!
    Have I to send all the parameters?


    Thanks for your help.
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    All functions require it that you send the full set of parameters. Just compare the record that you created with your function call with a record that you created in ispconfig to see the difference why yours dont work.
     
  14. skuli434

    skuli434 New Member

    Problem with password when adding new mailbox

    Guys, please help, I'm pulling my leftovers of my hair here

    I have taken the same configuration of remote API that adds mail_user database and i can view it in mail_user table , however when trying to open the mail trough roundcube webmail I cannot register, however when i go to ispconfig admin and change the password for the mailbox and save,
    wala i enter, and i dont want to reset manually the password for every creation I do.

    $params = array('server_id' => 1,
    'email' =>$full_insert_email,
    'login' =>$full_insert_email,
    'password' => $password2,
    'name' =>$_SESSION['eng_name1'],
    'uid' =>500,
    'gid' =>500,
    'maildir' => '/var/vmail/XXXX/'.$_insert_mail,
    'quota' => 104857600,
    'homedir' =>'/var/vmail/',
    'autoresponder' =>'n',
    'autoresponder_start_date' =>'',
    'autoresponder_end_date' =>'',
    'autoresponder_text' =>'',
    'move_junk' =>'n',
    'custom_mailfilter' =>'spam',
    'postfix' =>'y',
    'disableimap' =>'n',
    'disablepop3' =>'n',);
    $domain_id = $client->mail_user_add($session_id,1 , $params);


    Thank you
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    Compare the record that you inserted with the api with the record after you updated it in ispconfig to see which differences are causing the issue.
     
  16. skuli434

    skuli434 New Member

    Hi Till, Thank you for the reply
    I'm really puzzled about this thing. I enter the above parameters and then try to log in to roundcube and it doesn't do it,

    I have done as you said and the only thing that is not the same is password (encrypted one=$1$QlQgwqMy$iE8UYspAlqIX9nXqFYHx80 vs $1$Shloly56$AXmt3MoTga/g3K2LJV2wu/ ) inside mysql database in mail_user table.

    Please Help
     
  17. lyrano

    lyrano New Member

    nearly one year later :)

    i ran into the same issue, that everthing gets created but no login possible. In my case i had to set the homedir to '/var/vmail' and the login worked after that.
     
  18. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats correct, the homedir of a mail user has always to be set to root directory of the maildir structure which is normally /var/vmail. See example script in the remote api documentation in svn.
     

Share This Page