1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/teampass_ynh.git synced 2024-09-03 20:26:37 +02:00

Mise en place des modifs venant de l'autre serveur.

This commit is contained in:
Ackak 2015-12-06 12:49:32 +01:00
parent 86eff71e75
commit 0d926c93bf
13 changed files with 1016 additions and 22 deletions

15
README.md Normal file
View file

@ -0,0 +1,15 @@
Teampass for YunoHost
==================
[Yunohost project](https://yunohost.org/#/)
Gestionnaire de mot de passe collaboratif.
http://www.teampass.net
Le script installe le paquet *php5-cli*.
Teampass peut-être configuré uniquement via le compte administrateur. Pour cela il faut s'identifier avec admin et le mot de passe choisi à l'installation.
Pour utiliser la fonction de sauvegarde automatique, il est nécessaire de mettre en place un cron contenant ceci dans /etc/cron.d/teampass:
```0 0 * * * www-data cd /var/www/teampass/backups && php script.backup.php```

19
conf/mdphash.php Executable file
View file

@ -0,0 +1,19 @@
<?php
//function bCrypt tirée directement de sources/main.functions.php, ligne 223.
function bCrypt($password, $cost)
{
$salt = sprintf('$2y$%02d$', $cost);
if (function_exists('openssl_random_pseudo_bytes')) {
$salt .= bin2hex(openssl_random_pseudo_bytes(11));
} else {
$chars='./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for ($i=0; $i<22; $i++) {
$salt.=$chars[mt_rand(0, 63)];
}
}
return crypt($password, $salt);
}
// Le script prend en argument le mot de passe à chiffrer
echo bCrypt("$argv[1]",'13')."\n";
?>

View file

@ -1,17 +1,16 @@
location PATHTOCHANGE {
location __PATHTOCHANGE__ {
alias WWWPATH ;
alias __WWWPATH__ ;
index index.html index.php ;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass unix:/var/run/php5-fpm-__NAMETOCHANGE__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel.

392
conf/php-fpm.conf Normal file
View file

@ -0,0 +1,392 @@
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[__NAMETOCHANGE__]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 128
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1
; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; priority = -19
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 10
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 1
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
; pool: www
; process manager: static
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 62636
; accepted conn: 190460
; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the query string will return the corresponding
; output syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in µs of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: ${prefix}/share/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping
; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
; The access log file
; Default: not set
;access.log = log/$pool.access.log
; The access log format.
; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: ouput header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_slowlog_timeout = 5s
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = 10m
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = __FINALPATH__
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
catch_workers_output = yes
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr)
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

1
conf/php-fpm.ini Normal file
View file

@ -0,0 +1 @@
max_execution_time=60

417
conf/populate.sql Normal file
View file

@ -0,0 +1,417 @@
-- Infos à charger en base de donnée tirée du fichier install/install.queries.php. A partir de ligne 220
ALTER DATABASE `teampass` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `teampass`;
CREATE TABLE IF NOT EXISTS `teampass_items` (
`id` int(12) NOT null AUTO_INCREMENT,
`label` varchar(100) NOT NULL,
`description` text NOT NULL,
`pw` text NOT NULL,
`url` varchar(250) DEFAULT NULL,
`id_tree` varchar(10) DEFAULT NULL,
`perso` tinyint(1) NOT null DEFAULT '0',
`login` varchar(200) DEFAULT NULL,
`inactif` tinyint(1) NOT null DEFAULT '0',
`restricted_to` varchar(200) NOT NULL,
`anyone_can_modify` tinyint(1) NOT null DEFAULT '0',
`email` varchar(100) DEFAULT NULL,
`notification` varchar(250) DEFAULT NULL,
`viewed_no` int(12) NOT null DEFAULT '0',
`complexity_level` varchar(2) NOT null DEFAULT '-1',
PRIMARY KEY (`id`),
KEY `restricted_inactif_idx` (`restricted_to`,`inactif`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_log_items` (
`id_item` int(8) NOT NULL,
`date` varchar(50) NOT NULL,
`id_user` int(8) NOT NULL,
`action` varchar(250) NOT NULL,
`raison` text NOT NULL
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_misc` (
`type` varchar(50) NOT NULL,
`intitule` varchar(100) NOT NULL,
`valeur` varchar(100) NOT NULL
) CHARSET=utf8;
INSERT INTO `teampass_misc` (`type`, `intitule`, `valeur`) VALUES
('admin', 'max_latest_items', '10'),
('admin', 'enable_favourites', '1'),
('admin', 'show_last_items', '1'),
('admin', 'enable_pf_feature', '1'),
('admin', 'log_connections', '0'),
('admin', 'log_accessed', '0'),
('admin', 'time_format', 'H:i:s'),
('admin', 'date_format', 'd/m/Y'),
('admin', 'duplicate_folder', '0'),
('admin', 'item_duplicate_in_same_folder', '0'),
('admin', 'duplicate_item', '0'),
('admin', 'number_of_used_pw', '3'),
('admin', 'manager_edit', '1'),
('admin', 'cpassman_dir', '__FINALPATH__'),
('admin', 'cpassman_url', 'https://__DOMAIN____PATH__'),
('admin', 'favicon', 'https://__DOMAIN____PATH__/favico.ico'),
('admin', 'path_to_upload_folder', '__FINALPATH__/upload'),
('admin', 'url_to_upload_folder', 'https://__DOMAIN____PATH__/upload'),
('admin', 'path_to_files_folder', '__FINALPATH__/files'),
('admin', 'url_to_files_folder', 'https://__DOMAIN____PATH__/files'),
('admin', 'activate_expiration', '0'),
('admin','pw_life_duration','0'),
('admin','maintenance_mode','0'),
('admin','enable_sts','0'),
('admin','encryptClientServer','1'),
('admin','cpassman_version','__VERSION__'),
('admin','ldap_mode','1'),
('admin','ldap_type','posix-search'),
('admin','ldap_suffix','0'),
('admin','ldap_domain_dn','0'),
('admin','ldap_domain_controler','localhost'),
('admin','ldap_user_attribute','uid'),
('admin','ldap_search_base','ou=users,dc=yunohost,dc=org'),
('admin','ldap_ssl','0'),
('admin','ldap_tls','0'),
('admin','ldap_elusers','0'),
('admin','richtext','0'),
('admin','allow_print','1'),
('admin','roles_allowed_to_print','1'),
('admin','show_description','1'),
('admin','anyone_can_modify','0'),
('admin','anyone_can_modify_bydefault','0'),
('admin','nb_bad_authentication','0'),
('admin','utf8_enabled','1'),
('admin','restricted_to','0'),
('admin','restricted_to_roles','0'),
('admin','enable_send_email_on_user_login','0'),
('admin','enable_user_can_create_folders','1'),
('admin','insert_manual_entry_item_history','0'),
('admin','enable_kb','0'),
('admin','enable_email_notification_on_item_shown','0'),
('admin','enable_email_notification_on_user_pw_change','1'),
('admin','custom_logo',''),
('admin','custom_login_text',''),
('admin','default_language','__LANG__'),
('admin','send_stats', '0'),
('admin','get_tp_info', '1'),
('admin','send_mail_on_user_login', '0'),
('cron', 'sending_emails', '0'),
('admin','nb_items_by_query', 'auto'),
('admin','enable_delete_after_consultation', '0'),
('admin','enable_personal_saltkey_cookie', '0'),
('admin','personal_saltkey_cookie_duration', '31'),
('admin','email_smtp_server', 'localhost'),
('admin','email_smtp_auth', 'false'),
('admin','email_auth_username', ''),
('admin','email_auth_pwd', ''),
('admin','email_port', '465'),
('admin','email_security', 'ssl'),
('admin','email_server_url', 'https://__DOMAIN____PATH__'),
('admin','email_from', 'admin@__DOMAIN__'),
('admin','email_from_name', 'Teampass'),
('admin','pwd_maximum_length', '100'),
('admin','2factors_authentication', '0'),
('admin','delay_item_edition', '0'),
('admin','allow_import','1'),
('admin','proxy_ip',''),
('admin','proxy_port',''),
('admin','upload_maxfilesize','10mb'),
('admin','upload_docext','doc,docx,dotx,xls,xlsx,xltx,rtf,csv,txt,pdf,ppt,pptx,pot,dotx,xltx'),
('admin','upload_imagesext','jpg,jpeg,gif,png'),
('admin','upload_pkgext','7z,rar,tar,zip'),
('admin','upload_otherext','sql,xml'),
('admin','upload_imageresize_options','1'),
('admin','upload_imageresize_width','800'),
('admin','upload_imageresize_height','600'),
('admin','upload_imageresize_quality','90'),
('admin','use_md5_password_as_salt','1'),
('admin','ga_website_name','TeamPass for ChangeMe'),
('admin','api','0'),
('admin','subfolder_rights_as_parent','1'),
('admin','show_only_accessible_folders','1'),
('admin','enable_suggestion','0'),
('admin','otv_expiration_period','7'),
('admin', 'timezone', '__TIMEZONE__'),
('admin', 'can_create_root_folder', '1'),
('admin', 'settings_offline_mode', '1'),
('admin', 'offline_key_level', '50'),
('admin','default_session_expiration_time','60'),
('admin','bck_script_path','__FINALPATH__/backups/'),
('complex','1','0');
CREATE TABLE IF NOT EXISTS `teampass_nested_tree` (
`id` bigint(20) unsigned NOT null AUTO_INCREMENT,
`parent_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`nleft` int(11) NOT NULL DEFAULT '0',
`nright` int(11) NOT NULL DEFAULT '0',
`nlevel` int(11) NOT NULL DEFAULT '0',
`bloquer_creation` tinyint(1) NOT null DEFAULT '0',
`bloquer_modification` tinyint(1) NOT null DEFAULT '0',
`personal_folder` tinyint(1) NOT null DEFAULT '0',
`renewal_period` TINYINT(4) NOT null DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `nested_tree_parent_id` (`parent_id`),
KEY `nested_tree_nleft` (`nleft`),
KEY `nested_tree_nright` (`nright`),
KEY `nested_tree_nlevel` (`nlevel`),
KEY `personal_folder_idx` (`personal_folder`)
) CHARSET=utf8;
INSERT INTO teampass_nested_tree VALUES("1","0","__FOLDERS__","1","2","1","0","0","0","0");
CREATE TABLE IF NOT EXISTS `teampass_rights` (
`id` int(12) NOT null AUTO_INCREMENT,
`tree_id` int(12) NOT NULL,
`fonction_id` int(12) NOT NULL,
`authorized` tinyint(1) NOT null DEFAULT '0',
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_users` (
`id` int(12) NOT null AUTO_INCREMENT,
`login` varchar(50) NOT NULL,
`pw` varchar(400) NOT NULL,
`groupes_visibles` varchar(250) NOT NULL,
`derniers` text NOT NULL,
`key_tempo` varchar(100) NOT NULL,
`last_pw_change` varchar(30) NOT NULL,
`last_pw` text NOT NULL,
`admin` tinyint(1) NOT null DEFAULT '0',
`fonction_id` varchar(255) NOT NULL,
`groupes_interdits` varchar(255) NOT NULL,
`last_connexion` varchar(30) NOT NULL,
`gestionnaire` int(11) NOT null DEFAULT '0',
`email` varchar(300) NOT NULL,
`favourites` varchar(300) NOT NULL,
`latest_items` varchar(300) NOT NULL,
`personal_folder` int(1) NOT null DEFAULT '0',
`disabled` tinyint(1) NOT null DEFAULT '0',
`no_bad_attempts` tinyint(1) NOT null DEFAULT '0',
`can_create_root_folder` tinyint(1) NOT null DEFAULT '0',
`read_only` tinyint(1) NOT null DEFAULT '0',
`timestamp` varchar(30) NOT null DEFAULT '0',
`user_language` varchar(30) NOT null DEFAULT 'french',
`name` varchar(100) NULL,
`lastname` varchar(100) NULL,
`session_end` varchar(30) NULL,
`isAdministratedByRole` tinyint(5) NOT null DEFAULT '0',
`psk` varchar(400) NULL,
`ga` varchar(50) NULL,
`avatar` varchar(255) NOT null,
`avatar_thumb` varchar(255) NOT null,
PRIMARY KEY (`id`),
UNIQUE KEY `login` (`login`)
) CHARSET=utf8;
INSERT INTO `teampass_users` (`id`, `login`, `pw`, `groupes_visibles`, `derniers`, `key_tempo`, `last_pw_change`, `last_pw`, `admin`, `fonction_id`, `groupes_interdits`, `last_connexion`, `gestionnaire`, `email`, `favourites`, `latest_items`, `personal_folder`) VALUES
(NULL, 'admin', '__BCRYPT_MDP__', '', '', '', '', '', '1', '', '', '', '0', '', '', '', '0');
CREATE TABLE IF NOT EXISTS `teampass_tags` (
`id` int(12) NOT null AUTO_INCREMENT,
`tag` varchar(30) NOT NULL,
`item_id` int(12) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_log_system` (
`id` int(12) NOT null AUTO_INCREMENT,
`type` varchar(20) NOT NULL,
`date` varchar(30) NOT NULL,
`label` text NOT NULL,
`qui` varchar(30) NOT NULL,
`field_1` varchar(250) DEFAULT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_files` (
`id` int(11) NOT null AUTO_INCREMENT,
`id_item` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`size` int(10) NOT NULL,
`extension` varchar(10) NOT NULL,
`type` varchar(50) NOT NULL,
`file` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_cache` (
`id` int(12) NOT NULL,
`label` varchar(50) NOT NULL,
`description` text NOT NULL,
`tags` text NOT NULL,
`id_tree` int(12) NOT NULL,
`perso` tinyint(1) NOT NULL,
`restricted_to` varchar(200) NOT NULL,
`login` varchar(200) DEFAULT NULL,
`folder` varchar(300) NOT NULL,
`author` varchar(50) NOT NULL
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_roles_title` (
`id` int(12) NOT null AUTO_INCREMENT,
`title` varchar(50) NOT NULL,
`allow_pw_change` TINYINT(1) NOT null DEFAULT '0',
`complexity` INT(5) NOT null DEFAULT '0',
`creator_id` int(11) NOT null DEFAULT '0',
PRIMARY KEY (`id`)
) CHARSET=utf8;
INSERT INTO teampass_roles_title VALUES("1","__ROLES__","0","0","1");
CREATE TABLE IF NOT EXISTS `teampass_roles_values` (
`role_id` int(12) NOT NULL,
`folder_id` int(12) NOT NULL,
`type` varchar(1) NOT NULL DEFAULT 'R',
KEY `role_id_idx` (`role_id`)
) CHARSET=utf8;
INSERT INTO teampass_roles_values VALUES("1","1","W");
CREATE TABLE IF NOT EXISTS `teampass_kb` (
`id` int(12) NOT null AUTO_INCREMENT,
`category_id` int(12) NOT NULL,
`label` varchar(200) NOT NULL,
`description` text NOT NULL,
`author_id` int(12) NOT NULL,
`anyone_can_modify` tinyint(1) NOT null DEFAULT '0',
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_kb_categories` (
`id` int(12) NOT null AUTO_INCREMENT,
`category` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_kb_items` (
`kb_id` tinyint(12) NOT NULL,
`item_id` tinyint(12) NOT NULL
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_restriction_to_roles` (
`role_id` int(12) NOT NULL,
`item_id` int(12) NOT NULL,
KEY `role_id_idx` (`role_id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_keys` (
`sql_table` varchar(25) NOT NULL,
`id` int(20) NOT NULL,
`rand_key` varchar(25) NOT NULL,
UNIQUE KEY `rand_key_id_idx` (`rand_key`,`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_languages` (
`id` INT(10) NOT null AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR(50) NOT null ,
`label` VARCHAR(50) NOT null ,
`code` VARCHAR(10) NOT null ,
`flag` VARCHAR(30) NOT NULL
) CHARSET=utf8;
INSERT INTO `teampass_languages` (`name`, `label`, `code`, `flag`) VALUES
('french', 'French' , 'fr', 'fr.png'),
('english', 'English' , 'us', 'us.png'),
('spanish', 'Spanish' , 'es', 'es.png'),
('german', 'German' , 'de', 'de.png'),
('czech', 'Czech' , 'cz', 'cz.png'),
('italian', 'Italian' , 'it', 'it.png'),
('russian', 'Russian' , 'ru', 'ru.png'),
('turkish', 'Turkish' , 'tr', 'tr.png'),
('norwegian', 'Norwegian' , 'no', 'no.png'),
('japanese', 'Japanese' , 'ja', 'ja.png'),
('portuguese', 'Portuguese' , 'pr', 'pr.png'),
('chinese', 'Chinese' , 'cn', 'cn.png'),
('swedish', 'Swedish' , 'se', 'se.png'),
('dutch', 'Dutch' , 'nl', 'nl.png'),
('catalan', 'Catalan' , 'ct', 'ct.png');
CREATE TABLE IF NOT EXISTS `teampass_emails` (
`timestamp` INT(30) NOT null ,
`subject` VARCHAR(255) NOT null ,
`body` TEXT NOT null ,
`receivers` VARCHAR(255) NOT null ,
`status` VARCHAR(30) NOT NULL
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_automatic_del` (
`item_id` int(11) NOT NULL,
`del_enabled` tinyint(1) NOT NULL,
`del_type` tinyint(1) NOT NULL,
`del_value` varchar(35) NOT NULL
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_items_edition` (
`item_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`timestamp` varchar(50) NOT NULL
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_categories` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`parent_id` int(12) NOT NULL,
`title` varchar(255) NOT NULL,
`level` int(2) NOT NULL,
`description` text NOT NULL,
`type` varchar(50) NOT NULL,
`order` int(12) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_categories_items` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`field_id` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`data` text NOT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_categories_folders` (
`id_category` int(12) NOT NULL,
`id_folder` int(12) NOT NULL
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_api` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`type` varchar(15) NOT NULL,
`label` varchar(255) NOT NULL,
`value` varchar(255) NOT NULL,
`timestamp` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_otv` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`timestamp` text NOT NULL,
`code` varchar(100) NOT NULL,
`item_id` int(12) NOT NULL,
`originator` tinyint(12) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_suggestion` (
`id` tinyint(12) NOT NULL AUTO_INCREMENT,
`label` varchar(255) NOT NULL,
`password` text NOT NULL,
`description` text NOT NULL,
`author_id` int(12) NOT NULL,
`folder_id` int(12) NOT NULL,
`comment` text NOT NULL,
`suggestion_key` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `teampass_export` (
`id` int(12) NOT NULL,
`label` varchar(255) NOT NULL,
`login` varchar(100) NOT NULL,
`description` text NOT NULL,
`pw` text NOT NULL,
`path` varchar(255) NOT NULL
) CHARSET=utf8;

17
conf/settings.php Normal file
View file

@ -0,0 +1,17 @@
<?php
global $lang, $txt, $k, $pathTeampas, $urlTeampass, $pwComplexity, $mngPages;
global $server, $user, $pass, $database, $pre, $db, $port, $encoding;
### DATABASE connexion parameters ###
$server = "localhost";
$user = "__DBUSER__";
$pass = "__DBPWD__";
$database = "__DBUSER__";
$pre = "teampass_";
$port = 3306;
$encoding = "utf8";
@date_default_timezone_set($_SESSION['settings']['timezone']);
@define('SECUREPATH', '__FINALPATH__');
require_once "__SKPATH__sk.php";
?>

4
conf/sk.php Executable file
View file

@ -0,0 +1,4 @@
<?php
@define('SALT', '__SALTKEY__'); //Never Change it once it has been used !!!!!
@define('COST', '13'); // Don't change this.
?>

15
hooks/post_user_create Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
user=$1
root_pwd=$(sudo cat /etc/yunohost/mysql)
db_user=root
db_name=teampass
password=$(sudo php /var/www/teampass/mdphash.php $user)
mail=$(sudo ldapsearch -h localhost -b ou=users,dc=yunohost,dc=org -x uid=$user mail | grep mail: | sed 's/mail: //' | head -n1)
# Creation de l'utilisateur
mysql -u $db_user -p$root_pwd $db_name -e "INSERT INTO teampass_users (id, login, pw, groupes_visibles, derniers, key_tempo, last_pw_change, last_pw, admin, fonction_id, groupes_interdits, last_connexion, gestionnaire, email, favourites, latest_items, personal_folder, can_create_root_folder) VALUES (NULL, '$user', '$password', '1', '', '', '', '', '0', '1', '', '', '0', '$mail', '', '', '1', '1');"
# Creation du répertoire personnel
id=$(mysql -u $db_user -p$root_pwd $db_name -se "SELECT id from teampass_users where login='$user';")
mysql -u $db_user -p$root_pwd $db_name -e "INSERT INTO teampass_nested_tree (id, parent_id, title, nleft, nright, nlevel, bloquer_creation, bloquer_modification, personal_folder, renewal_period) VALUES (NULL, 0, '$id', 0, 0, 1, 0, 0, 1, 0);"

View file

@ -2,12 +2,14 @@
"name": "Teampass",
"id": "teampass",
"description": {
"en": "Passwords Manager",
"fr": "Gestionnaire de mots de passes."
},
"licence": "GPL-3",
"developer": {
"name": "Ackak",
"email": "ackak_ynh@ackak.net"
"version": "2.1.23",
"url": "http://www.teampass.net",
"maintainer": {
"name": "Ackak, Maniack Crudelis et matlink",
"email": "ackak_ynh@ackak.net maniackc_dev@crudelis.fr matlink@matlink.fr"
},
"multi_instance": "false",
"arguments": {
@ -16,7 +18,7 @@
"name": "domain",
"ask": {
"en": "Choose a domain for Teampass",
"fr": "Choisissez un domaine pour Teampass"
"fr": "Choisissez un domaine pour Teampass"
},
"example": "domain.org"
},
@ -28,6 +30,13 @@
},
"example": "/teampass",
"default": "/teampass"
},
{
"name": "password",
"ask": {
"en": "Choose a password for the admin",
"fr": "Choisissez un mot de passe pour l'administrateur"
}
}
]
}

View file

@ -4,6 +4,7 @@ app=teampass
# Retrieve arguments
domain=$1
path=$2
password_admin=$3
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
@ -16,30 +17,115 @@ fi
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
# Use 'teampass' as database name and user
db_user=teampass
db_user=$app
# Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd
sudo yunohost app setting teampass mysqlpwd -v $db_pwd
sudo yunohost app setting $app mysqlpwd -v $db_pwd
# Installation php5-mysqlnd
sudo apt-get -y install php5-mysqlnd
# Update php.ini
sudo sed -i "s@max_execution_time = 30@max_execution_time = 60@g" /etc/php5/fpm/php.ini
sudo service php5-fpm restart
sudo apt-get update
sudo apt-get -y install php5-cli
# Le paquetage php5-mysqlnd est demandé lors de l'installation de teampass, mais qui semble être non utilisé
#sudo apt-get -y install php5-mysqlnd
# Copy source files
final_path=/var/www/$app
sudo mkdir -p $final_path
sudo tar -xzf ../sources/teampass.tgz -C $final_path
tar -xf ../sources/teampass.tar.gz
sudo cp -a teampass/.* $final_path
sudo cp ../conf/mdphash.php $final_path
sudo chown -R www-data: $final_path
# Modify php-fpm pool configuration and copy it to php-fpm pool directory for teampass
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
sudo cp ../conf/php-fpm.ini $finalphpini
sudo chown root: $finalphpini
sudo service php5-fpm reload
# Remplacement des variables dans le fichier sql
if [ $(echo $LANG | cut -c1-2) == "fr" ]
then
langue=french
folders=partagés
roles=utilisateurs
else
langue=english
folders=shared
roles=users
fi
sed -i "s@__FINALPATH__@$final_path@g" ../conf/populate.sql
sed -i "s@__DOMAIN__@$domain@g" ../conf/populate.sql
sed -i "s@__PATH__@$path@g" ../conf/populate.sql
sed -i "s@__FOLDERS__@$folders@g" ../conf/populate.sql
sed -i "s@__ROLES__@$roles@g" ../conf/populate.sql
sed -i "s@__VERSION__@$(cat $final_path/changelog.md | head -1)@g" ../conf/populate.sql
sed -i "s@__TIMEZONE__@$(cat /etc/timezone)@g" ../conf/populate.sql
sed -i "s@__BCRYPT_MDP__@$(php ../conf/mdphash.php $password_admin)@g" ../conf/populate.sql
sed -i "s@__LANG__@$langue@g" ../conf/populate.sql
# Add settings to YunoHost
sudo yunohost app setting $app domain -v $domain
sudo yunohost app setting $app path -v $path
sudo yunohost app setting $app final_path -v $final_path
sudo yunohost app setting $app langue -v $langue
# Import du fichier SQL
mysql -u $db_user -p$db_pwd $db_user < ../conf/populate.sql
# Remplacement des variables dans les fichier settings.php et sk.php
sed -i "s@__DBUSER__@$db_user@g" ../conf/settings.php
sed -i "s@__DBPWD__@$db_pwd@g" ../conf/settings.php
sed -i "s@__FINALPATH__@$final_path@g" ../conf/settings.php
path_sk_file=/etc/teampass/
sudo mkdir $path_sk_file
sed -i "s@__SKPATH__@$path_sk_file@g" ../conf/settings.php
saltkey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{32\}\).*/\1/p')
sed -i "s@__SALTKEY__@$saltkey@g" ../conf/sk.php
# Et copie des fichiers à leurs emplacements.
sudo cp ../conf/sk.php $path_sk_file/sk.php
sudo chown -R www-data:www-data $path_sk_file
sudo chmod 770 $path_sk_file
sudo cp ../conf/settings.php $final_path/includes/settings.php
sudo chown www-data: -R $final_path
sudo chmod 770 -R $final_path
sudo find $final_path -type f -print0 | xargs -0 sudo chmod 740 # Applique les permissions sur les fichiers seulement (rwxr-----)
sudo chmod 770 -R $final_path/files $final_path/upload
# Delete the install directory. Si cette méthode d'install est validée, le dossier install devrait être retiré de l'archive initiale.
sudo rm -r $final_path/install
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@WWWPATH@$final_path@g" ../conf/nginx.conf
sed -i "s@__PATHTOCHANGE__@$path@g" ../conf/nginx.conf
sed -i "s@__WWWPATH__@$final_path@g" ../conf/nginx.conf
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Ajout des utilisateurs actuels dans la base yunohost
teampass_users=$(ldapsearch -h localhost -b ou=users,dc=yunohost,dc=org -x objectClass=mailAccount uid | grep uid: | sed 's/uid: //' | xargs)
id=1
for teampassuser in $teampass_users
do
password=$(php ../conf/mdphash.php $teampassuser)
mail=$(sudo ldapsearch -h localhost -b ou=users,dc=yunohost,dc=org -x uid=$teampassuser mail | grep mail: | sed 's/mail: //' | head -n1)
# Creation de l'utilisateur
mysql -u $db_user -p$db_pwd $db_user -e "INSERT INTO teampass_users (id, login, pw, groupes_visibles, derniers, key_tempo, last_pw_change, last_pw, admin, fonction_id, groupes_interdits, last_connexion, gestionnaire, email, favourites, latest_items, personal_folder, can_create_root_folder) VALUES (NULL, '$teampassuser', '$password', '1', '', '', '', '', '0', '1', '', '', '0', '$mail', '', '', '1', '1');"
# Creation du repertoire personnel
id_user=$(mysql -u $db_user -p$db_pwd $db_user -se "SELECT id from teampass_users where login='$teampassuser';")
mysql -u $db_user -p$db_pwd $db_user -e "INSERT INTO teampass_nested_tree (id, parent_id, title, nleft, nright, nlevel, bloquer_creation, bloquer_modification, personal_folder, renewal_period) VALUES (NULL, 0, '$id_user', 0, 0, 1, 0, 0, 1, 0);"
((id++))
done
# Restart services
sudo service nginx reload
sudo yunohost app ssowatconf

View file

@ -11,11 +11,20 @@ sudo rm -rf /var/www/$app
# Remove configuration files
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
db_user=teampass
db_name=teampass
#Remove the sk.php
sudo rm -rf /etc/teampass/
# Suppression de la config php-fpm
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
sudo rm -f /etc/php5/fpm/conf.d/20-$app.ini
db_user=$app
db_name=$app
root_pwd=$(sudo cat /etc/yunohost/mysql)
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
# Restart services
sudo service nginx reload
sudo yunohost app ssowatconf
sudo service php5-fpm reload

View file

@ -4,15 +4,26 @@ app=teampass
# Retrieve arguments
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
final_path=$(sudo yunohost app setting $app final_path)
# Remove trailing "/" for next commands
path=${path%/}
# Copy source files
final_path=/var/www/$app
sudo mkdir -p $final_path
sudo cp -a ../sources/* $final_path
# Modify php-fpm pool configuration and copy it to php-fpm pool directory for teampass
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
sudo cp ../conf/php-fpm.ini $finalphpini
sudo chown root: $finalphpini
sudo service php5-fpm reload
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf