| | 1954 | |
|---|
| | 1955 | ################################################################################ |
|---|
| | 1956 | ## |
|---|
| | 1957 | ## alias proftpd data managment; |
|---|
| | 1958 | ## |
|---|
| | 1959 | ################################################################################ |
|---|
| | 1960 | |
|---|
| | 1961 | ################################################################################ |
|---|
| | 1962 | ## |
|---|
| | 1963 | ## |
|---|
| | 1964 | ## |
|---|
| | 1965 | sub als_add_proftpd_cfg_data { |
|---|
| | 1966 | my ($als_data) = @_; |
|---|
| | 1967 | my ($rs, $rdata) = (undef, undef); |
|---|
| | 1968 | |
|---|
| | 1969 | push_el(\@main::el, 'als_add_proftpd_cfg_data()', 'Starting...'); |
|---|
| | 1970 | |
|---|
| | 1971 | if (!defined($als_data) || $als_data eq '') { |
|---|
| | 1972 | push_el(\@main::el, 'als_add_proftpd_cfg_data()', 'ERROR: Undefined Input Data...'); |
|---|
| | 1973 | return -1; |
|---|
| | 1974 | } |
|---|
| | 1975 | |
|---|
| | 1976 | # |
|---|
| | 1977 | # Initial data we need; |
|---|
| | 1978 | # |
|---|
| | 1979 | my $als_name = @$als_data[2]; |
|---|
| | 1980 | my $als_mount_point = @$als_data[4]; |
|---|
| | 1981 | my $als_to = @$als_data[8]; |
|---|
| | 1982 | |
|---|
| | 1983 | my $conf_dir = $main::cfg{'CONF_DIR'}; |
|---|
| | 1984 | my $proftpd_conf_dir = $main::cfg{'FTPD_CONF_DIR'}; |
|---|
| | 1985 | my $apache_www_dir = $main::cfg{'APACHE_WWW_DIR'}; |
|---|
| | 1986 | |
|---|
| | 1987 | my $tpl_dir = "$conf_dir/proftpd/parts"; |
|---|
| | 1988 | my $backup_dir = "$conf_dir/proftpd/backup"; |
|---|
| | 1989 | my $working_dir = "$conf_dir/proftpd/working"; |
|---|
| | 1990 | my $als_fname = "$als_name.conf"; |
|---|
| | 1991 | my $als_path = "$apache_www_dir/$als_to$als_mount_point"; |
|---|
| | 1992 | my $working_cfg = "$working_dir/$als_fname"; |
|---|
| | 1993 | my $sys_cfg = "$proftpd_conf_dir/$als_fname"; |
|---|
| | 1994 | |
|---|
| | 1995 | # |
|---|
| | 1996 | # Let's get needed tags and templates; |
|---|
| | 1997 | # |
|---|
| | 1998 | my $entry = ''; |
|---|
| | 1999 | ($rs, $entry) = get_tpl( |
|---|
| | 2000 | $tpl_dir, |
|---|
| | 2001 | 'proftpd.conf.tpl' |
|---|
| | 2002 | ); |
|---|
| | 2003 | return $rs if ($rs != 0); |
|---|
| | 2004 | |
|---|
| | 2005 | # |
|---|
| | 2006 | # Let's prepare them; |
|---|
| | 2007 | # |
|---|
| | 2008 | my %tag_hash = ( |
|---|
| | 2009 | '{PATH}' => $als_path, |
|---|
| | 2010 | ); |
|---|
| | 2011 | ($rs, $entry) = prep_tpl( |
|---|
| | 2012 | \%tag_hash, |
|---|
| | 2013 | $entry |
|---|
| | 2014 | ); |
|---|
| | 2015 | return $rs if ($rs != 0); |
|---|
| | 2016 | |
|---|
| | 2017 | # |
|---|
| | 2018 | # Let's store generated data; |
|---|
| | 2019 | # |
|---|
| | 2020 | $rs = store_file($working_cfg, $entry, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644); |
|---|
| | 2021 | return $rs if ($rs != 0); |
|---|
| | 2022 | |
|---|
| | 2023 | $rs = store_file($sys_cfg, $entry, $main::cfg{'ROOT_USER'}, $main::cfg{'ROOT_GROUP'}, 0644); |
|---|
| | 2024 | return $rs if ($rs != 0); |
|---|
| | 2025 | |
|---|
| | 2026 | push_el(\@main::el, 'als_add_proftpd_cfg_data()', 'Ending...'); |
|---|
| | 2027 | return 0; |
|---|
| | 2028 | } |
|---|
| | 2029 | |
|---|
| | 2030 | ################################################################################ |
|---|
| | 2031 | ################################################################################ |
|---|
| | 2032 | ## |
|---|
| | 2033 | ## |
|---|
| | 2034 | ## |
|---|
| | 2035 | sub als_del_proftpd_cfg_data { |
|---|
| | 2036 | my ($als_data) = @_; |
|---|
| | 2037 | my ($rs, $rdata) = (undef, undef); |
|---|
| | 2038 | |
|---|
| | 2039 | push_el(\@main::el, 'als_del_proftpd_cfg_data()', 'Starting...'); |
|---|
| | 2040 | if (!defined($als_data) || $als_data eq '') { |
|---|
| | 2041 | push_el(\@main::el, 'als_del_proftpd_cfg_data()', 'ERROR: Undefined Input Data...'); |
|---|
| | 2042 | return -1; |
|---|
| | 2043 | } |
|---|
| | 2044 | |
|---|
| | 2045 | # |
|---|
| | 2046 | # Initial data we need; |
|---|
| | 2047 | # |
|---|
| | 2048 | |
|---|
| | 2049 | my $als_name = @$als_data[2]; |
|---|
| | 2050 | my $conf_dir = $main::cfg{'CONF_DIR'}; |
|---|
| | 2051 | my $proftpd_conf_dir = $main::cfg{'FTPD_CONF_DIR'}; |
|---|
| | 2052 | my $als_fname = "$als_name.conf"; |
|---|
| | 2053 | my $working_dir = "$conf_dir/proftpd/working"; |
|---|
| | 2054 | my $working_cfg = "$working_dir/$als_fname"; |
|---|
| | 2055 | my $sys_cfg = "$proftpd_conf_dir/$als_fname"; |
|---|
| | 2056 | |
|---|
| | 2057 | # |
|---|
| | 2058 | # Let's remove .db files for this domain; |
|---|
| | 2059 | # |
|---|
| | 2060 | $rs = del_file($working_cfg); |
|---|
| | 2061 | return $rs if ($rs != 0); |
|---|
| | 2062 | |
|---|
| | 2063 | $rs = del_file($sys_cfg); |
|---|
| | 2064 | return $rs if ($rs != 0); |
|---|
| | 2065 | |
|---|
| | 2066 | push_el(\@main::el, 'als_del_proftpd_cfg_data()', 'Ending...'); |
|---|
| | 2067 | return 0; |
|---|
| | 2068 | } |
|---|
| | 2069 | |
|---|
| | 2070 | ################################################################################ |
|---|
| | 2071 | ################################################################################ |
|---|
| | 2072 | ## |
|---|
| | 2073 | ## |
|---|
| | 2074 | ## |
|---|
| | 2075 | sub als_add_proftpd_data { |
|---|
| | 2076 | my ($als_data) = @_; |
|---|
| | 2077 | my $rs = undef; |
|---|
| | 2078 | |
|---|
| | 2079 | push_el(\@main::el, 'als_add_proftpd_data()', 'Starting...'); |
|---|
| | 2080 | if (!defined($als_data) || $als_data eq '') { |
|---|
| | 2081 | push_el(\@main::el, 'als_add_proftpd_data()', 'ERROR: Undefined Input Data...'); |
|---|
| | 2082 | return -1; |
|---|
| | 2083 | } |
|---|
| | 2084 | return 0 if ($main::cfg{'CMD_NAMED'} eq 'no'); |
|---|
| | 2085 | |
|---|
| | 2086 | $rs = als_add_proftpd_cfg_data($als_data); |
|---|
| | 2087 | return $rs if ($rs != 0); |
|---|
| | 2088 | |
|---|
| | 2089 | push_el(\@main::el, 'als_add_proftpd_data()', 'Ending...'); |
|---|
| | 2090 | return 0; |
|---|
| | 2091 | } |
|---|
| | 2092 | |
|---|
| | 2093 | ################################################################################ |
|---|
| | 2094 | ################################################################################ |
|---|
| | 2095 | ## |
|---|
| | 2096 | ## |
|---|
| | 2097 | ## |
|---|
| | 2098 | sub als_change_proftpd_data { |
|---|
| | 2099 | my ($als_data) = @_; |
|---|
| | 2100 | my $rs = undef; |
|---|
| | 2101 | |
|---|
| | 2102 | push_el(\@main::el, 'als_change_proftpd_data()', 'Starting...'); |
|---|
| | 2103 | if (!defined($als_data) || $als_data eq '') { |
|---|
| | 2104 | push_el(\@main::el, 'als_change_proftpd_data()', 'ERROR: Undefined Input Data...'); |
|---|
| | 2105 | return -1; |
|---|
| | 2106 | } |
|---|
| | 2107 | return 0 if ($main::cfg{'CMD_NAMED'} eq 'no'); |
|---|
| | 2108 | |
|---|
| | 2109 | $rs = als_add_proftpd_data($als_data); |
|---|
| | 2110 | return $rs if ($rs != 0); |
|---|
| | 2111 | |
|---|
| | 2112 | push_el(\@main::el, 'als_change_proftpd_data()', 'Ending...'); |
|---|
| | 2113 | return 0; |
|---|
| | 2114 | } |
|---|
| | 2115 | |
|---|
| | 2116 | ################################################################################ |
|---|
| | 2117 | ################################################################################ |
|---|
| | 2118 | ## |
|---|
| | 2119 | ## |
|---|
| | 2120 | ## |
|---|
| | 2121 | sub als_del_proftpd_data { |
|---|
| | 2122 | my ($als_data) = @_; |
|---|
| | 2123 | my $rs = undef; |
|---|
| | 2124 | |
|---|
| | 2125 | push_el(\@main::el, 'als_del_proftpd_data()', 'Starting...'); |
|---|
| | 2126 | if (!defined($als_data) || $als_data eq '') { |
|---|
| | 2127 | push_el(\@main::el, 'als_del_proftpd_data()', 'ERROR: Undefined Input Data...'); |
|---|
| | 2128 | return -1; |
|---|
| | 2129 | } |
|---|
| | 2130 | return 0 if ($main::cfg{'CMD_NAMED'} eq 'no'); |
|---|
| | 2131 | |
|---|
| | 2132 | $rs = als_del_proftpd_cfg_data($als_data); |
|---|
| | 2133 | return $rs if ($rs != 0); |
|---|
| | 2134 | |
|---|
| | 2135 | push_el(\@main::el, 'als_del_proftpd_data()', 'Ending...'); |
|---|
| | 2136 | return 0; |
|---|
| | 2137 | } |
|---|
| | 2138 | |
|---|