Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Flag debug as rootcmd #613

Merged
merged 1 commit into from Sep 16, 2018
Merged

Flag debug as rootcmd #613

merged 1 commit into from Sep 16, 2018

Conversation

jsegaert
Copy link
Contributor

Make sure to follow and check these boxes before submitting a PR! Thank you.

When running iocage debug as non-root user, one gets a Traceback. This fix is to require running this command as root.

/home/jurgen/iocage jurgen@trinity%  iocage debug
Traceback (most recent call last):
  File "/usr/local/bin/iocage", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/iocage_cli/debug.py", line 38, in cli
    ioc.IOCage().debug(directory)
  File "/usr/local/lib/python3.6/site-packages/iocage_lib/iocage.py", line 1855, in debug
    ioc_debug.IOCDebug(directory).run_debug()
  File "/usr/local/lib/python3.6/site-packages/iocage_lib/ioc_debug.py", line 61, in run_debug
    self.run_host_debug()
  File "/usr/local/lib/python3.6/site-packages/iocage_lib/ioc_debug.py", line 78, in run_host_debug
    self.__write_debug__(zfs_datasets, host_path, 'ZFS')
  File "/usr/local/lib/python3.6/site-packages/iocage_lib/ioc_debug.py", line 128, in __write_debug__
    with open(f'{path}.txt', 'a+') as f:
PermissionError: [Errno 13] Permission denied: '/iocage/debug/host.txt'

@skarekrow
Copy link
Member

D'oh! Good catch

@skarekrow skarekrow merged commit 0374d7e into iocage:master Sep 16, 2018
@jsegaert jsegaert deleted the debug_rootcmd branch September 16, 2018 05:54
skarekrow pushed a commit to truenas/iocage that referenced this pull request Oct 4, 2018
* We want unix acl's on iocage's datasets

FreeNAS Ticket: #38195

* DNS/SRV/Host fixes

- Parse out the host name, you can't query SRV records from an HTTP
  address
- Don't die if SRV records aren't found, just log it
- pkg-repository(5) doesn't appear to enforce or require SRV records
- TrueOS pkg mirrors work fine without SRV records

* Use branches with plugins

This allows us to freeze the INDEX and do development without users being impacted. In addition safe guard against plugins requiring new iocage features.

FreeNAS Ticket: #39638

* Use branches with plugins

This allows us to freeze the INDEX and do development without users being impacted. In addition safe guard against plugins requiring new iocage features.

FreeNAS Ticket: #39638

* Travis

* Check host release for plugins

- Also commonize the method

FreeNAS Ticket: #39508

* Trrrrravis

* Strip subnet of IP4_ADDR when building plugin's portal URL (iocage#586)

* Check release upon create (iocage#589)

* Always Force unmount Datasets when renaming (iocage#590)

* Remove exit_on_error

This is redundant, as it's already the case.

Related to FreeNAS TIcket: #36948

* Check DNS for plugins

- Return a more useful pkg error
- Show more information about the install process
- General formatting improvements
- Tear down jail if DHCP fails
- Tear down jail if VNET fails
- Tear down jail if pkg upgrade fails in plugin installs (required for mismatched ABI errors from previous pkg)

FreeNAS Ticket: #40106

* Flatten Python module names (iocage#592)

* rename iocage.lib to iocage_lib

* rename iocage/cli to iocage_cli

* update setup.py to iocage_lib and iocage_cli

* move manpage files to top directory

* move icage/tests/ to top level directory

* add missing dev dependency mock

* gitignore .pytest_cache/

* remove deprecated iocage/ directory

* ./iocage script for local cli testing/development

* Refactor callback method, 

- Also add callback to many places in plugins
- Correctly pass callback into fetch method
- Return the command output message for plugins

FreeNAS Ticket: #36948

* Bump copyright year (better late then never?)

* Fix a couple typos

* Add a debug command

This should help with tickets that need to supply information

* Creating duplicate plugins now name them plugin_NUM

- Fix upgrading for plugins
- Fix jail creation to be basejails for plugins (They were before, but not actually removing any data)

* We want file, not http when specified

This fixes some logic.

Closes iocage#597

* Be less nice for plugin pkg's clogging up stdout

FreeNAS TIcket: #42018

* Fix Makefile names

* Make some plugin exec changes to hopefully address FreeNAS #42018

* Prevent CPU from spinning on plugin tasks

* Fix callback usage in lib/iocage

This was incorrectly calling None on API usage.

FreeNAS Ticket: #42359

* Read output one more time after is finished (iocage#601)

* Change devfs rule generation

- DHCP is much more flexible now
- Plugins are able to have devfs rules specified in their manifests
- Plugin manifests are kept around for devfs rules now, possibly more fun later

FreeNAS Ticket: #42593

* Fix a couple issues with devfs generation

* Only show one interface for the plugin IP

Most plugins that have more then one IP use VNET, so this assumes the first interface to be the default one.

FreeNAS Ticket: #42641

* Update py-libzfs

Closes issues iocage#602, iocage#505, #153

* Fix usage of git@ repos

This allows private repos to be used as plugins.

FreeNAS Ticket: #42653

* fixes BUG, return was one level high (iocage#603)

* Merge pull request #17 from freenas/ticket-41694

Delete jails in case of plugin install failure

* Initialize reference to repo after succesful porcelain.pull() (iocage#606)

* adds thickjail feature to man (iocage#604)

* Fix debug not being as useful as it should be for non-running jails

- Also append .txt to the filenames.
- Drop jexec for most of the debug to instead opt for grabbing from the filesystem directly

FreeNAS Ticket: #45563

* Correctly create aliases for shared IP jails that don't specify iface

It seems jail(8) behavior may have changed, and this is now required for jail to create the aliases. We do a best effort attempt at using the default interface if the user doesn't supply one.

The idea is that if they didn't supply one, they may have already set the alias up themselves, so iocage will do nothing in this case.

FreeNAS Ticket: #46245

* Fixed a bug in fstab

This commit fixes a bug which caused iocage to raise an exception incase an edit/removal was required by index only and destination field was passed on as null in fstab.
Ticket: #45783

* Remove duplicate variable

This would be fatal possibly.

* Let's use the right variable

Possibly shadowing before anyways, this is better.

* Updates to iocage.8: (iocage#612)

- Update entry for ip4_addr to remove text about entering DEFAULT.
- Fix up entry for vnet_interfaces.
- Manual check of iocage.8: no issues.

* Silence!

* Improved error handling

This commit adds a try catch block to a snippet where while removing a file may raise an exception as it might not exist in the first place.
Ticket: #45805

* Potential Bug fix for jail creation

This commit fixes a potential bug which possible arose due to a race condition when the system was unable to find a newly created file. The original referenced issue couldn't be reproduced but necessary steps have been taken to avoid this behavior in this commit.
Ticket: #43119

* Test variable before splitting again, honor IP only for plugin install

This would be fatal if they didn't supply an interface, in addition we don't care about the interface here, so these block's aren't useful.

FreeNAS Ticket: #41670

* Flag debug as rootcmd (iocage#613)

* Fix branch name for plugin repo (iocage#614)

* Don't use ifconfig -f inet:cidr to extract IP/Mask... (iocage#515)

* Don't use ifconfig -f inet:cidr to extract IP/Mask, this is only supported by FreeBSD 11 and newer

* efficiencyfied a redundant operation, reordered for readability, and added comments

* Moved the [2] up to original assignment of addr_split

* Fix devfs rules that have a bracket

add path 'ulpt[0-9]*' mode 666 and such.

FreeNAS Ticket: #46920

* Use a specific exception for pool activation issues

FreeNAS Ticket: #45760

* Merge pull request #37 from freenas/ticket-47085

Bug fix for MAC Addresses

* Be a better env...izen. Less pollution!

FreeNAS Ticket: #46491

* @william-gr noted we should probably have a couple nice defaults

env shouldn't be *so* empty.

* Fix wrong property in doc

* Add "allow_mlock" as a new property (iocage#617)

Introduced in FreeBSD 12.0. Enables running services that
require mlock() in a jail (e.g. MongoDB)

* Do not set allow.mlock when userland < 12.0 (iocage#619)

* Bug fix for installing packages (iocage#607)

This commit fixes a bug which caused an exception when trying to install plugins or packages with no packages specified to be installed.
Ticket: #44735

* Retry on pkg and pkg install failures

Currently we just assume it succeeds or fails, when it could be a slight transient issue.

FreeNAS Ticket: #44834

* What! No sys.exit.

Raise instead.

FreeNAS Ticket: 44834

* Remove debug, add better messages.

* It's not even Monday!

* Tighten up reusage of code for retry

This is better, suggested by William.

* Let's add the string version of the exception too

Why not! Another idea of @william-gr

* Yeah, once is enough for the pkg error

* Add rtsold support

This works much like dhcp, just easier if you have an ipv6 network. Just set the ip6_addr to 'vnet0|accept_rtadv'

FreeNAS Ticket: #40468

* keep_jail_on_failure should be a flag

Previously it required a boolean.

FreeNAS Ticket: #48416

* Fixed iocage list multiple IP4 addresses (iocage#621)

* fixed iocage list: show multiple IP4 addresses correctly

* Fixed long lines in ioc_list.py

*  Fixed bug: Jail fails to start when depends jail is already running (iocage#608) (iocage#622)

* Fixed bug: Jail fails to start when depends jail is already running (iocage#608)

* Fixed bug iocage#608: If dependent jail does not start then parent jail is not started
* Added JailRunning exception and use it when dependent jails already started
* Added force_raise flag to default callback() function to force raising exception

* Fix exec_pre|post stop

Previous behavior was borked. It now works.

Closes iocage#611
FreeNAS TIcket: #48449

* Make default interface for vnet customizable (iocage#623)

This commit adds support for customizing the default interface for vnet which should be attached on the relevant bridge. It updates the properties of the jails by adding a new property which is used when starting vnet jails.
Ticket: #40484

* Fixed bug: setting ZFS properties via 'iocage set' raised exception (iocage#624)

* Allow unhiding tun devices with a custom prop "allow_tun"

This can be either 0 or 1. This change will also make devfs rulesets individual for each jail that sets dhcp or allow_tun. But it also means you can combine them now.

FreeNAS Ticket: #40872

* Catch by @william-gr

* exec_clean now affects exec as expected.

Upstream required -l to be passed to jexec to clean the environment. Otherwise it was just for the jail initialization.

Closes: iocage#610
FreeNAS Ticket: #48581

* Fix Traceback when pkg-static install fails (iocage#627)

* Decomplicate things and just use pool/iocage as mount

Previous behavior could cause us headaches if exporting and importing other pools. In addition it's heavily overengineered.

FreeNAS Ticket: #41268

* We want the jails fstab in debug

FreeNAS Ticket: #49420

* Improve support for dots in jailname (iocage#629)

* Improve support for dots in jailname

* Improve support for dots in jailname (req. chngs)
skarekrow pushed a commit to truenas/iocage that referenced this pull request Oct 4, 2018
* We want unix acl's on iocage's datasets

FreeNAS Ticket: #38195

* DNS/SRV/Host fixes

- Parse out the host name, you can't query SRV records from an HTTP
  address
- Don't die if SRV records aren't found, just log it
- pkg-repository(5) doesn't appear to enforce or require SRV records
- TrueOS pkg mirrors work fine without SRV records

* Use branches with plugins

This allows us to freeze the INDEX and do development without users being impacted. In addition safe guard against plugins requiring new iocage features.

FreeNAS Ticket: #39638

* Use branches with plugins

This allows us to freeze the INDEX and do development without users being impacted. In addition safe guard against plugins requiring new iocage features.

FreeNAS Ticket: #39638

* Travis

* Check host release for plugins

- Also commonize the method

FreeNAS Ticket: #39508

* Trrrrravis

* Strip subnet of IP4_ADDR when building plugin's portal URL (iocage#586)

* Check release upon create (iocage#589)

* Always Force unmount Datasets when renaming (iocage#590)

* Remove exit_on_error

This is redundant, as it's already the case.

Related to FreeNAS TIcket: #36948

* Check DNS for plugins

- Return a more useful pkg error
- Show more information about the install process
- General formatting improvements
- Tear down jail if DHCP fails
- Tear down jail if VNET fails
- Tear down jail if pkg upgrade fails in plugin installs (required for mismatched ABI errors from previous pkg)

FreeNAS Ticket: #40106

* Flatten Python module names (iocage#592)

* rename iocage.lib to iocage_lib

* rename iocage/cli to iocage_cli

* update setup.py to iocage_lib and iocage_cli

* move manpage files to top directory

* move icage/tests/ to top level directory

* add missing dev dependency mock

* gitignore .pytest_cache/

* remove deprecated iocage/ directory

* ./iocage script for local cli testing/development

* Refactor callback method, 

- Also add callback to many places in plugins
- Correctly pass callback into fetch method
- Return the command output message for plugins

FreeNAS Ticket: #36948

* Bump copyright year (better late then never?)

* Fix a couple typos

* Add a debug command

This should help with tickets that need to supply information

* Creating duplicate plugins now name them plugin_NUM

- Fix upgrading for plugins
- Fix jail creation to be basejails for plugins (They were before, but not actually removing any data)

* We want file, not http when specified

This fixes some logic.

Closes iocage#597

* Be less nice for plugin pkg's clogging up stdout

FreeNAS TIcket: #42018

* Fix Makefile names

* Make some plugin exec changes to hopefully address FreeNAS #42018

* Prevent CPU from spinning on plugin tasks

* Fix callback usage in lib/iocage

This was incorrectly calling None on API usage.

FreeNAS Ticket: #42359

* Read output one more time after is finished (iocage#601)

* Change devfs rule generation

- DHCP is much more flexible now
- Plugins are able to have devfs rules specified in their manifests
- Plugin manifests are kept around for devfs rules now, possibly more fun later

FreeNAS Ticket: #42593

* Fix a couple issues with devfs generation

* Only show one interface for the plugin IP

Most plugins that have more then one IP use VNET, so this assumes the first interface to be the default one.

FreeNAS Ticket: #42641

* Update py-libzfs

Closes issues iocage#602, iocage#505, #153

* Fix usage of git@ repos

This allows private repos to be used as plugins.

FreeNAS Ticket: #42653

* fixes BUG, return was one level high (iocage#603)

* Merge pull request #17 from freenas/ticket-41694

Delete jails in case of plugin install failure

* Initialize reference to repo after succesful porcelain.pull() (iocage#606)

* adds thickjail feature to man (iocage#604)

* Fix debug not being as useful as it should be for non-running jails

- Also append .txt to the filenames.
- Drop jexec for most of the debug to instead opt for grabbing from the filesystem directly

FreeNAS Ticket: #45563

* Correctly create aliases for shared IP jails that don't specify iface

It seems jail(8) behavior may have changed, and this is now required for jail to create the aliases. We do a best effort attempt at using the default interface if the user doesn't supply one.

The idea is that if they didn't supply one, they may have already set the alias up themselves, so iocage will do nothing in this case.

FreeNAS Ticket: #46245

* Fixed a bug in fstab

This commit fixes a bug which caused iocage to raise an exception incase an edit/removal was required by index only and destination field was passed on as null in fstab.
Ticket: #45783

* Remove duplicate variable

This would be fatal possibly.

* Let's use the right variable

Possibly shadowing before anyways, this is better.

* Updates to iocage.8: (iocage#612)

- Update entry for ip4_addr to remove text about entering DEFAULT.
- Fix up entry for vnet_interfaces.
- Manual check of iocage.8: no issues.

* Silence!

* Improved error handling

This commit adds a try catch block to a snippet where while removing a file may raise an exception as it might not exist in the first place.
Ticket: #45805

* Potential Bug fix for jail creation

This commit fixes a potential bug which possible arose due to a race condition when the system was unable to find a newly created file. The original referenced issue couldn't be reproduced but necessary steps have been taken to avoid this behavior in this commit.
Ticket: #43119

* Test variable before splitting again, honor IP only for plugin install

This would be fatal if they didn't supply an interface, in addition we don't care about the interface here, so these block's aren't useful.

FreeNAS Ticket: #41670

* Flag debug as rootcmd (iocage#613)

* Fix branch name for plugin repo (iocage#614)

* Don't use ifconfig -f inet:cidr to extract IP/Mask... (iocage#515)

* Don't use ifconfig -f inet:cidr to extract IP/Mask, this is only supported by FreeBSD 11 and newer

* efficiencyfied a redundant operation, reordered for readability, and added comments

* Moved the [2] up to original assignment of addr_split

* Fix devfs rules that have a bracket

add path 'ulpt[0-9]*' mode 666 and such.

FreeNAS Ticket: #46920

* Use a specific exception for pool activation issues

FreeNAS Ticket: #45760

* Merge pull request #37 from freenas/ticket-47085

Bug fix for MAC Addresses

* Be a better env...izen. Less pollution!

FreeNAS Ticket: #46491

* @william-gr noted we should probably have a couple nice defaults

env shouldn't be *so* empty.

* Fix wrong property in doc

* Add "allow_mlock" as a new property (iocage#617)

Introduced in FreeBSD 12.0. Enables running services that
require mlock() in a jail (e.g. MongoDB)

* Do not set allow.mlock when userland < 12.0 (iocage#619)

* Bug fix for installing packages (iocage#607)

This commit fixes a bug which caused an exception when trying to install plugins or packages with no packages specified to be installed.
Ticket: #44735

* Retry on pkg and pkg install failures

Currently we just assume it succeeds or fails, when it could be a slight transient issue.

FreeNAS Ticket: #44834

* What! No sys.exit.

Raise instead.

FreeNAS Ticket: 44834

* Remove debug, add better messages.

* It's not even Monday!

* Tighten up reusage of code for retry

This is better, suggested by William.

* Let's add the string version of the exception too

Why not! Another idea of @william-gr

* Yeah, once is enough for the pkg error

* Add rtsold support

This works much like dhcp, just easier if you have an ipv6 network. Just set the ip6_addr to 'vnet0|accept_rtadv'

FreeNAS Ticket: #40468

* keep_jail_on_failure should be a flag

Previously it required a boolean.

FreeNAS Ticket: #48416

* Fixed iocage list multiple IP4 addresses (iocage#621)

* fixed iocage list: show multiple IP4 addresses correctly

* Fixed long lines in ioc_list.py

*  Fixed bug: Jail fails to start when depends jail is already running (iocage#608) (iocage#622)

* Fixed bug: Jail fails to start when depends jail is already running (iocage#608)

* Fixed bug iocage#608: If dependent jail does not start then parent jail is not started
* Added JailRunning exception and use it when dependent jails already started
* Added force_raise flag to default callback() function to force raising exception

* Fix exec_pre|post stop

Previous behavior was borked. It now works.

Closes iocage#611
FreeNAS TIcket: #48449

* Make default interface for vnet customizable (iocage#623)

This commit adds support for customizing the default interface for vnet which should be attached on the relevant bridge. It updates the properties of the jails by adding a new property which is used when starting vnet jails.
Ticket: #40484

* Fixed bug: setting ZFS properties via 'iocage set' raised exception (iocage#624)

* Allow unhiding tun devices with a custom prop "allow_tun"

This can be either 0 or 1. This change will also make devfs rulesets individual for each jail that sets dhcp or allow_tun. But it also means you can combine them now.

FreeNAS Ticket: #40872

* Catch by @william-gr

* exec_clean now affects exec as expected.

Upstream required -l to be passed to jexec to clean the environment. Otherwise it was just for the jail initialization.

Closes: iocage#610
FreeNAS Ticket: #48581

* Fix Traceback when pkg-static install fails (iocage#627)

* Decomplicate things and just use pool/iocage as mount

Previous behavior could cause us headaches if exporting and importing other pools. In addition it's heavily overengineered.

FreeNAS Ticket: #41268

* We want the jails fstab in debug

FreeNAS Ticket: #49420

* Improve support for dots in jailname (iocage#629)

* Improve support for dots in jailname

* Improve support for dots in jailname (req. chngs)

* Make default interface for vnet customizable

This commit adds support for customizing the default interface for vnet which should be attached on the relevant bridge. It updates the properties of the jails by adding a new property which is used when starting vnet jails.
Ticket: #40484

* This commit adds support for a default none value for vnet_default_interface property

* Don't use ifconfig -f inet:cidr to extract IP/Mask... (iocage#515)

* Don't use ifconfig -f inet:cidr to extract IP/Mask, this is only supported by FreeBSD 11 and newer

* efficiencyfied a redundant operation, reordered for readability, and added comments

* Moved the [2] up to original assignment of addr_split

* Improve validation for VNET MAC Fields

This commit improves validation for vnet mac props by ensuring that a valid mac address is specified each time with taking into account that the addresses aren't repeated.
Ticket: #45838

* Update py-libzfs.
skarekrow pushed a commit that referenced this pull request Sep 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants