def load_auth_settings():
  d = None
  conn = None
  try :
    d = db.read_single_row("%s/integral_view_config.db"%db_path, "select * from samba_global_common where id=1")
    if d and d["security"] == "ads":
      d1 = db.read_single_row("%s/integral_view_config.db"%db_path, "select * from samba_global_ad where id=1")
      if d1:
        d.update(d1)
  finally:
    return d
예제 #2
0
def get_log_level():
    d = None
    conn = None
    log_level = None
    try:
        d, err = db.read_single_row(db_path,
                                    "select * from global_params where id=1")
        if err:
            raise Exception(err)
        if d and "logging_level" in d:
            log_level = d["logging_level"]
        else:
            #Not yet set so insert the default and return it
            cmd_list = []
            cmd = [
                "insert into global_params (logging_level, id) values(?,?)",
                (
                    logging.INFO,
                    1,
                )
            ]
            cmd_list.append(cmd)
            ret, err = db.execute_iud(db_path, cmd_list)
            if err:
                raise Exception(err)
            log_level = logging.INFO
    except Exception, e:
        return None, "Error getting log level : %s" % str(e)
예제 #3
0
def save_auth_settings(d):

    try:
        db_path, err = common.get_db_path()
        if err:
            raise Exception(err)
        cmd = [
            "update samba_global_common set workgroup=?, netbios_name=?, security=?, include_homes_section=? where id = ?",
            (
                d["workgroup"],
                d["netbios_name"],
                d["security"],
                True,
                1,
            )
        ]
        cmd_list = []
        cmd_list.append(cmd)
        if d["security"] == "ads":
            d1, err = db.read_single_row(db_path,
                                         "select * from samba_global_ad")
            if err:
                raise Exception(err)
            if d1:
                cmd = [
                    "update samba_global_ad set realm=?, password_server=?, ad_schema_mode=?, id_map_min=?, id_map_max=?, password_server_ip=?  where id = ?",
                    (
                        d["realm"],
                        d["password_server"],
                        'rfc2307',
                        16777216,
                        33554431,
                        d["password_server_ip"],
                        1,
                    )
                ]
                cmd_list.append(cmd)
            else:
                cmd = [
                    "insert into samba_global_ad (realm, password_server, ad_schema_mode, id_map_min, id_map_max, password_server_ip, id) values(?,?,?,?,?,?,?)",
                    (
                        d["realm"],
                        d["password_server"],
                        'rfc2307',
                        16777216,
                        33554431,
                        d["password_server_ip"],
                        1,
                    )
                ]
                cmd_list.append(cmd)
        #print cmd_list
        ret, err = db.execute_iud(db_path, cmd_list)
        if err:
            raise Exception(err)
    except Exception, e:
        return False, 'Error saving authentication settings : %s' % str(e)
예제 #4
0
def load_auth_settings():
    d = None
    try:
        db_path, err = common.get_db_path()
        if err:
            raise Exception(err)
        d, err = db.read_single_row(
            db_path, "select * from samba_global_common where id=1")
        if err:
            raise Exception(err)
        if d and d["security"] == "ads":
            d1, err = db.read_single_row(
                db_path, "select * from samba_global_ad where id=1")
            if err:
                raise Exception(err)
            if d1:
                d.update(d1)
    except Exception, e:
        return None, 'Error loading authentication settings : %s' % str(e)
예제 #5
0
def set_log_level(level):
    if level not in [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]:
        logger.setLevel(logging.INFO)
    else:
        d1 = db.read_single_row("%s/integral_view_config.db" % db_path, "select * from global_params")
        cmd_list = []
        if d1:
            cmd = ["update global_params set logging_level=? where id = ?", (level, 1)]
        else:
            cmd = ["insert into global_params (logging_level, id) values(?,?)", (level, 1)]
        cmd_list.append(cmd)
        db.execute_iud("%s/integral_view_config.db" % db_path, cmd_list)
        logger.setLevel(level)
예제 #6
0
def save_email_settings(d):

    conn = None
    try:
        db_path, err = common.get_db_path()
        if err:
            raise Exception(err)
        d1, err = db.read_single_row(db_path, "select * from email_config")
        if err:
            raise Exception(err)
        if d1:
            #Config exists so update
            ret, err = db.execute_iud(db_path, [[
                "update email_config set server=?, port=?, username=?, pswd=?, tls=?, email_alerts=?, email_audit=?, email_quota=?, rcpt_list=? where id = ?",
                (
                    d["server"],
                    d["port"],
                    d["username"],
                    d["pswd"],
                    d["tls"],
                    d["email_alerts"],
                    d["email_audit"],
                    d["email_quota"],
                    d["rcpt_list"],
                    1,
                )
            ]])
            if err:
                raise Exception(err)

        else:
            #No config exists so insert
            ret, err = db.execute_iud(db_path, [[
                "insert into email_config (server, port, username, pswd, tls, email_alerts,email_audit,email_quota, rcpt_list, id) values (?,?,?,?,?,?,?,?,?,?)",
                (
                    d["server"],
                    d["port"],
                    d["username"],
                    d["pswd"],
                    d["tls"],
                    d["email_alerts"],
                    d["email_audit"],
                    d["email_quota"],
                    d["rcpt_list"],
                    1,
                )
            ]])
            if err:
                raise Exception(err)
    except Exception, e:
        return False, 'Error saving email settings : %s' % str(e)
예제 #7
0
def load_email_settings():
    conn = None
    d = None
    try:
        #print '1'
        db_path, err = common.get_db_path()
        #print '2'
        if err:
            raise Exception(err)
        d, err = db.read_single_row(db_path,
                                    "select * from email_config where id = 1")
        if err:
            raise Exception(err)
    except Exception, e:
        return None, 'Error loading email settings : %s' % str(e)
예제 #8
0
def get_log_level():
    d = None
    conn = None
    try:
        d = db.read_single_row("%s/integral_view_config.db" % db_path, "select * from global_params where id=1")
        if d and "logging_level" in d:
            return d["logging_level"]
        else:
            # Not yet set so insert the default and return it
            cmd_list = []
            cmd = ["insert into global_params (logging_level, id) values(?,?)", (logging.INFO, 1)]
            cmd_list.append(cmd)
            db.execute_iud("%s/integral_view_config.db" % db_path, cmd_list)
            return logging.INFO
    except Exception, e:
        print "Error inserting log level : %s" % str(e)
def get_task(task_id):
    task = None
    try:

        db_path, err = common.get_db_path()
        if err:
            raise Exception(err)

        cmd = "select * from tasks where task_id=='%d'" % int(task_id)
        task, err = db.read_single_row(db_path, cmd)
        if err:
            raise Exception(err)
        if not task:
            raise Exception('Selected task not found')
    except Exception, e:
        return None, 'Error retrieving task details : %s' % e
예제 #10
0
def load_share_info(mode, index):
    d = None
    try:
        db_path, err = common.get_db_path()
        if err:
            raise Exception(err)
        query = None
        if mode == "by_id":
            query = "select * from samba_shares where share_id = %s" % index
        else:
            query = "select * from samba_shares where name = %s" % index
        d, err = db.read_single_row(db_path, query)
        if err:
            raise Exception(err)

    except Exception, e:
        return None, 'Error loading CIFS share information : %s' % str(e)
def save_auth_settings(d):

  cmd_list = []
  cmd = ["update samba_global_common set workgroup=?, netbios_name=?, security=?, include_homes_section=? where id = ?", (d["workgroup"], d["netbios_name"], d["security"], True, 1,)]
  cmd_list.append(cmd)
  if d["security"] == "ads":
    d1 = db.read_single_row("%s/integral_view_config.db"%db_path, "select * from samba_global_ad")
    if d1:
      #cmd = ["update samba_global_ad set realm=?, password_server=?, ad_schema_mode=?, id_map_min=?, id_map_max=?  where id = ?", (d["realm"], d["password_server"], d["ad_schema_mode"], d["id_map_min"], d["id_map_max"], 1,)]
      cmd = ["update samba_global_ad set realm=?, password_server=?, ad_schema_mode=?, id_map_min=?, id_map_max=?, password_server_ip=?  where id = ?", (d["realm"], d["password_server"], 'rfc2307', 16777216, 33554431, d["password_server_ip"], 1, )]
      cmd_list.append(cmd)
    else:
      #cmd = ["insert into samba_global_ad (realm, password_server, ad_schema_mode, id_map_min, id_map_max, id) values(?,?,?,?,?,?)", (d["realm"], d["password_server"], d["ad_schema_mode"], d["id_map_min"], d["id_map_max"], 1,)]
      cmd = ["insert into samba_global_ad (realm, password_server, ad_schema_mode, id_map_min, id_map_max, password_server_ip, id) values(?,?,?,?,?,?,?)", (d["realm"], d["password_server"], 'rfc2307', 16777216, 33554431, d["password_server_ip"], 1,)]
      cmd_list.append(cmd)
  #print cmd_list
  #Always try to create the fractalio_guest account for guest access - will fail if it exists so ok
  try:
    local_users.create_local_user('fractalio_guest', 'Fractalio_Guest_User', 'fractalioguest')
  except Exception, e:
    pass
예제 #12
0
def set_log_level(level):
    try:
        db_path, err = common.get_db_path()
        if err:
            raise Exception(err)
        if level not in [
                logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,
                logging.CRITICAL
        ]:
            logger.setLevel(logging.INFO)
        else:
            d1, err = db.read_single_row(db_path,
                                         "select * from global_params")
            if err:
                raise Exception(err)
            cmd_list = []
            if d1:
                cmd = [
                    "update global_params set logging_level=? where id = ?",
                    (
                        level,
                        1,
                    )
                ]
            else:
                cmd = [
                    "insert into global_params (logging_level, id) values(?,?)",
                    (
                        level,
                        1,
                    )
                ]
            cmd_list.append(cmd)
            ret, err = db.execute_iud(db_path, cmd_list)
            if err:
                raise Exception(err)
            logger.setLevel(level)
    except Exception, e:
        return False, 'Error setting log level : %s' % str(e)
def set_log_level(level):
  try:
    db_path, err = common.get_db_path()
    if err:
      raise Exception(err)
    if level not in [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]:
      logger.setLevel(logging.INFO)
    else:
      d1, err = db.read_single_row("%s/integral_view_config.db"%db_path, "select * from global_params")
      if err:
        raise Exception(err)
      cmd_list = []
      if d1:
        cmd = ["update global_params set logging_level=? where id = ?", (level, 1,)]
      else:
        cmd = ["insert into global_params (logging_level, id) values(?,?)", (level, 1,)]
      cmd_list.append(cmd)
      ret, err = db.execute_iud("%s/integral_view_config.db"%db_path, cmd_list)
      if err:
        raise Exception(err)
      logger.setLevel(level)
  except Exception, e:
    return False, 'Error setting log level : %s'%str(e)