Opened 5 years ago

Last modified 3 years ago

#58785 new defect

If port select fails, it can leave an incomplete or inconsistent set of symlinks

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by:
Priority: Normal Milestone:
Component: base Version: 2.5.4
Keywords: Cc: cooljeanius (Eric Gallager)
Port:

Description

If port select fails, for example due to a bug in a portfile such that only some of the files to which symlinks will be made actually exist, then the user's system can be left in an inconsistent state.

For example, currently sudo port select mysql mariadb works but #58197 reports that sudo port select mysql mysql57 fails. If I run both of those commands in that order, some of the symlinks are now pointing to mysql57 files while others are left still pointing at mariadb files:

$ ls -l $(sed 's,^,/opt/local/,' /opt/local/etc/select/mysql/base) 2>/dev/null
lrwxr-xr-x  1 root  wheel  39 Aug  2 08:07 /opt/local/bin/innochecksum -> /opt/local/lib/mysql57/bin/innochecksum
lrwxr-xr-x  1 root  wheel  41 Aug  2 08:07 /opt/local/bin/lz4_decompress -> /opt/local/lib/mysql57/bin/lz4_decompress
lrwxr-xr-x  1 root  wheel  44 Aug  2 08:07 /opt/local/bin/my_print_defaults -> /opt/local/lib/mysql57/bin/my_print_defaults
lrwxr-xr-x  1 root  wheel  40 Aug  2 08:07 /opt/local/bin/myisam_ftdump -> /opt/local/lib/mysql57/bin/myisam_ftdump
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/myisamchk -> /opt/local/lib/mysql57/bin/myisamchk
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/myisamlog -> /opt/local/lib/mysql57/bin/myisamlog
lrwxr-xr-x  1 root  wheel  37 Aug  2 08:07 /opt/local/bin/myisampack -> /opt/local/lib/mysql57/bin/myisampack
lrwxr-xr-x  1 root  wheel  32 Aug  2 08:07 /opt/local/bin/mysql -> /opt/local/lib/mysql57/bin/mysql
lrwxr-xr-x  1 root  wheel  44 Aug  2 08:07 /opt/local/bin/mysql_client_test -> /opt/local/lib/mysql57/bin/mysql_client_test
lrwxr-xr-x  1 root  wheel  53 Aug  2 08:07 /opt/local/bin/mysql_client_test_embedded -> /opt/local/lib/mysql57/bin/mysql_client_test_embedded
lrwxr-xr-x  1 root  wheel  39 Aug  2 08:07 /opt/local/bin/mysql_config -> /opt/local/lib/mysql57/bin/mysql_config
lrwxr-xr-x  1 root  wheel  46 Aug  2 08:07 /opt/local/bin/mysql_config_editor -> /opt/local/lib/mysql57/bin/mysql_config_editor
lrwxr-xr-x  1 root  wheel  41 Aug  2 08:07 /opt/local/bin/mysql_embedded -> /opt/local/lib/mysql57/bin/mysql_embedded
lrwxr-xr-x  1 root  wheel  43 Aug  2 08:07 /opt/local/bin/mysql_install_db -> /opt/local/lib/mysql57/bin/mysql_install_db
lrwxr-xr-x  1 root  wheel  39 Aug  2 08:07 /opt/local/bin/mysql_plugin -> /opt/local/lib/mysql57/bin/mysql_plugin
lrwxr-xr-x  1 root  wheel  52 Aug  2 08:07 /opt/local/bin/mysql_secure_installation -> /opt/local/lib/mysql57/bin/mysql_secure_installation
lrwxr-xr-x  1 root  wheel  46 Aug  2 08:07 /opt/local/bin/mysql_ssl_rsa_setup -> /opt/local/lib/mysql57/bin/mysql_ssl_rsa_setup
lrwxr-xr-x  1 root  wheel  46 Aug  2 08:07 /opt/local/bin/mysql_tzinfo_to_sql -> /opt/local/lib/mysql57/bin/mysql_tzinfo_to_sql
lrwxr-xr-x  1 root  wheel  40 Aug  2 08:07 /opt/local/bin/mysql_upgrade -> /opt/local/lib/mysql57/bin/mysql_upgrade
lrwxr-xr-x  1 root  wheel  37 Aug  2 08:07 /opt/local/bin/mysqladmin -> /opt/local/lib/mysql57/bin/mysqladmin
lrwxr-xr-x  1 root  wheel  38 Aug  2 08:07 /opt/local/bin/mysqlbinlog -> /opt/local/lib/mysql57/bin/mysqlbinlog
lrwxr-xr-x  1 root  wheel  37 Aug  2 08:07 /opt/local/bin/mysqlcheck -> /opt/local/lib/mysql57/bin/mysqlcheck
lrwxr-xr-x  1 root  wheel  33 Aug  2 08:07 /opt/local/bin/mysqld -> /opt/local/lib/mysql57/bin/mysqld
lrwxr-xr-x  1 root  wheel  39 Aug  2 08:07 /opt/local/bin/mysqld_multi -> /opt/local/lib/mysql57/bin/mysqld_multi
lrwxr-xr-x  1 root  wheel  38 Aug  2 08:07 /opt/local/bin/mysqld_safe -> /opt/local/lib/mysql57/bin/mysqld_safe
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/mysqldump -> /opt/local/lib/mysql57/bin/mysqldump
lrwxr-xr-x  1 root  wheel  40 Aug  2 08:07 /opt/local/bin/mysqldumpslow -> /opt/local/lib/mysql57/bin/mysqldumpslow
lrwxr-xr-x  1 root  wheel  38 Aug  2 08:07 /opt/local/bin/mysqlimport -> /opt/local/lib/mysql57/bin/mysqlimport
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/mysqlpump -> /opt/local/lib/mysql57/bin/mysqlpump
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/mysqlshow -> /opt/local/lib/mysql57/bin/mysqlshow
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/mysqlslap -> /opt/local/lib/mysql57/bin/mysqlslap
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/mysqltest -> /opt/local/lib/mysql57/bin/mysqltest
lrwxr-xr-x  1 root  wheel  45 Aug  2 08:07 /opt/local/bin/mysqltest_embedded -> /opt/local/lib/mysql57/bin/mysqltest_embedded
lrwxr-xr-x  1 root  wheel  33 Aug  2 08:07 /opt/local/bin/perror -> /opt/local/lib/mysql57/bin/perror
lrwxr-xr-x  1 root  wheel  34 Aug  2 08:07 /opt/local/bin/replace -> /opt/local/lib/mysql57/bin/replace
lrwxr-xr-x  1 root  wheel  45 Aug  2 08:07 /opt/local/bin/resolve_stack_dump -> /opt/local/lib/mysql57/bin/resolve_stack_dump
lrwxr-xr-x  1 root  wheel  36 Aug  2 08:07 /opt/local/bin/resolveip -> /opt/local/lib/mysql57/bin/resolveip
lrwxr-xr-x  1 root  wheel  42 Aug  2 08:07 /opt/local/bin/zlib_decompress -> /opt/local/lib/mysql57/bin/zlib_decompress
lrwxr-xr-x  1 root  wheel  47 Aug  2 08:07 /opt/local/man/man1/comp_err.1.gz -> /opt/local/share/man/mysql57/man1/comp_err.1.gz
lrwxr-xr-x  1 root  wheel  51 Aug  2 08:07 /opt/local/man/man1/innochecksum.1.gz -> /opt/local/share/man/mysql57/man1/innochecksum.1.gz
lrwxr-xr-x  1 root  wheel  53 Aug  2 08:07 /opt/local/man/man1/lz4_decompress.1.gz -> /opt/local/share/man/mysql57/man1/lz4_decompress.1.gz
lrwxr-xr-x  1 root  wheel  56 Aug  2 08:07 /opt/local/man/man1/my_print_defaults.1.gz -> /opt/local/share/man/mysql57/man1/my_print_defaults.1.gz
lrwxr-xr-x  1 root  wheel  52 Aug  2 08:07 /opt/local/man/man1/myisam_ftdump.1.gz -> /opt/local/share/man/mysql57/man1/myisam_ftdump.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:07 /opt/local/man/man1/myisamchk.1.gz -> /opt/local/share/man/mysql57/man1/myisamchk.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:07 /opt/local/man/man1/myisamlog.1.gz -> /opt/local/share/man/mysql57/man1/myisamlog.1.gz
lrwxr-xr-x  1 root  wheel  49 Aug  2 08:07 /opt/local/man/man1/myisampack.1.gz -> /opt/local/share/man/mysql57/man1/myisampack.1.gz
lrwxr-xr-x  1 root  wheel  56 Aug  2 08:06 /opt/local/man/man1/mysql-test-run.pl.1.gz -> /opt/local/share/man/mariadb/man1/mysql-test-run.pl.1.gz
lrwxr-xr-x  1 root  wheel  44 Aug  2 08:06 /opt/local/man/man1/mysql.1.gz -> /opt/local/share/man/mariadb/man1/mysql.1.gz
lrwxr-xr-x  1 root  wheel  51 Aug  2 08:06 /opt/local/man/man1/mysql.server.1.gz -> /opt/local/share/man/mariadb/man1/mysql.server.1.gz
lrwxr-xr-x  1 root  wheel  56 Aug  2 08:06 /opt/local/man/man1/mysql_client_test.1.gz -> /opt/local/share/man/mariadb/man1/mysql_client_test.1.gz
lrwxr-xr-x  1 root  wheel  65 Aug  2 08:06 /opt/local/man/man1/mysql_client_test_embedded.1.gz -> /opt/local/share/man/mariadb/man1/mysql_client_test_embedded.1.gz
lrwxr-xr-x  1 root  wheel  51 Aug  2 08:06 /opt/local/man/man1/mysql_config.1.gz -> /opt/local/share/man/mariadb/man1/mysql_config.1.gz
lrwxr-xr-x  1 root  wheel  65 Aug  2 08:06 /opt/local/man/man1/mysql_convert_table_format.1.gz -> /opt/local/share/man/mariadb/man1/mysql_convert_table_format.1.gz
lrwxr-xr-x  1 root  wheel  54 Aug  2 08:06 /opt/local/man/man1/mysql_find_rows.1.gz -> /opt/local/share/man/mariadb/man1/mysql_find_rows.1.gz
lrwxr-xr-x  1 root  wheel  59 Aug  2 08:06 /opt/local/man/man1/mysql_fix_extensions.1.gz -> /opt/local/share/man/mariadb/man1/mysql_fix_extensions.1.gz
lrwxr-xr-x  1 root  wheel  55 Aug  2 08:06 /opt/local/man/man1/mysql_install_db.1.gz -> /opt/local/share/man/mariadb/man1/mysql_install_db.1.gz
lrwxr-xr-x  1 root  wheel  51 Aug  2 08:06 /opt/local/man/man1/mysql_plugin.1.gz -> /opt/local/share/man/mariadb/man1/mysql_plugin.1.gz
lrwxr-xr-x  1 root  wheel  64 Aug  2 08:06 /opt/local/man/man1/mysql_secure_installation.1.gz -> /opt/local/share/man/mariadb/man1/mysql_secure_installation.1.gz
lrwxr-xr-x  1 root  wheel  58 Aug  2 08:06 /opt/local/man/man1/mysql_setpermission.1.gz -> /opt/local/share/man/mariadb/man1/mysql_setpermission.1.gz
lrwxr-xr-x  1 root  wheel  58 Aug  2 08:06 /opt/local/man/man1/mysql_tzinfo_to_sql.1.gz -> /opt/local/share/man/mariadb/man1/mysql_tzinfo_to_sql.1.gz
lrwxr-xr-x  1 root  wheel  52 Aug  2 08:06 /opt/local/man/man1/mysql_upgrade.1.gz -> /opt/local/share/man/mariadb/man1/mysql_upgrade.1.gz
lrwxr-xr-x  1 root  wheel  52 Aug  2 08:06 /opt/local/man/man1/mysql_waitpid.1.gz -> /opt/local/share/man/mariadb/man1/mysql_waitpid.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:06 /opt/local/man/man1/mysql_zap.1.gz -> /opt/local/share/man/mariadb/man1/mysql_zap.1.gz
lrwxr-xr-x  1 root  wheel  50 Aug  2 08:06 /opt/local/man/man1/mysqlaccess.1.gz -> /opt/local/share/man/mariadb/man1/mysqlaccess.1.gz
lrwxr-xr-x  1 root  wheel  49 Aug  2 08:06 /opt/local/man/man1/mysqladmin.1.gz -> /opt/local/share/man/mariadb/man1/mysqladmin.1.gz
lrwxr-xr-x  1 root  wheel  50 Aug  2 08:06 /opt/local/man/man1/mysqlbinlog.1.gz -> /opt/local/share/man/mariadb/man1/mysqlbinlog.1.gz
lrwxr-xr-x  1 root  wheel  47 Aug  2 08:06 /opt/local/man/man1/mysqlbug.1.gz -> /opt/local/share/man/mariadb/man1/mysqlbug.1.gz
lrwxr-xr-x  1 root  wheel  49 Aug  2 08:06 /opt/local/man/man1/mysqlcheck.1.gz -> /opt/local/share/man/mariadb/man1/mysqlcheck.1.gz
lrwxr-xr-x  1 root  wheel  51 Aug  2 08:06 /opt/local/man/man1/mysqld_multi.1.gz -> /opt/local/share/man/mariadb/man1/mysqld_multi.1.gz
lrwxr-xr-x  1 root  wheel  50 Aug  2 08:06 /opt/local/man/man1/mysqld_safe.1.gz -> /opt/local/share/man/mariadb/man1/mysqld_safe.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:06 /opt/local/man/man1/mysqldump.1.gz -> /opt/local/share/man/mariadb/man1/mysqldump.1.gz
lrwxr-xr-x  1 root  wheel  52 Aug  2 08:06 /opt/local/man/man1/mysqldumpslow.1.gz -> /opt/local/share/man/mariadb/man1/mysqldumpslow.1.gz
lrwxr-xr-x  1 root  wheel  51 Aug  2 08:06 /opt/local/man/man1/mysqlhotcopy.1.gz -> /opt/local/share/man/mariadb/man1/mysqlhotcopy.1.gz
lrwxr-xr-x  1 root  wheel  50 Aug  2 08:06 /opt/local/man/man1/mysqlimport.1.gz -> /opt/local/share/man/mariadb/man1/mysqlimport.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:06 /opt/local/man/man1/mysqlshow.1.gz -> /opt/local/share/man/mariadb/man1/mysqlshow.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:06 /opt/local/man/man1/mysqlslap.1.gz -> /opt/local/share/man/mariadb/man1/mysqlslap.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:06 /opt/local/man/man1/mysqltest.1.gz -> /opt/local/share/man/mariadb/man1/mysqltest.1.gz
lrwxr-xr-x  1 root  wheel  57 Aug  2 08:06 /opt/local/man/man1/mysqltest_embedded.1.gz -> /opt/local/share/man/mariadb/man1/mysqltest_embedded.1.gz
lrwxr-xr-x  1 root  wheel  45 Aug  2 08:06 /opt/local/man/man1/perror.1.gz -> /opt/local/share/man/mariadb/man1/perror.1.gz
lrwxr-xr-x  1 root  wheel  46 Aug  2 08:06 /opt/local/man/man1/replace.1.gz -> /opt/local/share/man/mariadb/man1/replace.1.gz
lrwxr-xr-x  1 root  wheel  57 Aug  2 08:06 /opt/local/man/man1/resolve_stack_dump.1.gz -> /opt/local/share/man/mariadb/man1/resolve_stack_dump.1.gz
lrwxr-xr-x  1 root  wheel  48 Aug  2 08:06 /opt/local/man/man1/resolveip.1.gz -> /opt/local/share/man/mariadb/man1/resolveip.1.gz
lrwxr-xr-x  1 root  wheel  45 Aug  2 08:06 /opt/local/man/man8/mysqld.8.gz -> /opt/local/share/man/mariadb/man8/mysqld.8.gz

Ideally port select should either fully succeed or it should leave the disk untouched.

The first idea that occurred to me is that it should clean up after a failed attempt, but that might be tough, and just trying to re-select the user's previous selection in case of an error might also fail.

So maybe this second idea is better: It could do two passes through all the files to be symlinked. The first pass would just verify that all the files to be linked do in fact exist, and the second pass would do the actual linking.

Change History (1)

comment:1 Changed 3 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.