Remove feature flag for VNet launch daemon (#44923)

* Do not execute vnet-admin-setup if tsh was built with daemon support

* Remove feature flag

* Don't show background item notification when launch daemon is not supported

* Update docs

* Fix typo

Co-authored-by: Grzegorz Zdunek <[email protected]>

---------

Co-authored-by: Grzegorz Zdunek <[email protected]>
This commit is contained in:
Rafał Cieślak
2024-08-01 15:53:13 +00:00
committed by GitHub
co-authored by Grzegorz Zdunek
parent 1b685dbf9f
commit 856c588564
14 changed files with 167 additions and 102 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 KiB

After

Width:  |  Height:  |  Size: 173 KiB

+4 -3
View File
@@ -32,9 +32,10 @@ have `tcp://` as the protocol in their addresses.
Click "Connect" next to the TCP app. This starts VNet if it's not already running. Alternatively,
you can start VNet through the connection list in the top left.
VNet needs to set up a network device and configure DNS on your device, so it'll ask for admin
permissions. For now your password is needed each time you start VNet, but we're working on showing
the prompt only once.
During the first launch, macOS will prompt you to enable a background item for tsh.app. VNet needs
this background item in order to configure DNS on your device. To enable the background item, either
interact with the system notification or go to System Settings > General > Login Items and look for
tsh.app under "Allow in the Background".
![VNet starting up](../../img/use-teleport/[email protected])
@@ -48,6 +48,7 @@ const (
BackgroundItemStatus_BACKGROUND_ITEM_STATUS_ENABLED BackgroundItemStatus = 2
BackgroundItemStatus_BACKGROUND_ITEM_STATUS_REQUIRES_APPROVAL BackgroundItemStatus = 3
BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_FOUND BackgroundItemStatus = 4
BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_SUPPORTED BackgroundItemStatus = 5
)
// Enum value maps for BackgroundItemStatus.
@@ -58,6 +59,7 @@ var (
2: "BACKGROUND_ITEM_STATUS_ENABLED",
3: "BACKGROUND_ITEM_STATUS_REQUIRES_APPROVAL",
4: "BACKGROUND_ITEM_STATUS_NOT_FOUND",
5: "BACKGROUND_ITEM_STATUS_NOT_SUPPORTED",
}
BackgroundItemStatus_value = map[string]int32{
"BACKGROUND_ITEM_STATUS_UNSPECIFIED": 0,
@@ -65,6 +67,7 @@ var (
"BACKGROUND_ITEM_STATUS_ENABLED": 2,
"BACKGROUND_ITEM_STATUS_REQUIRES_APPROVAL": 3,
"BACKGROUND_ITEM_STATUS_NOT_FOUND": 4,
"BACKGROUND_ITEM_STATUS_NOT_SUPPORTED": 5,
}
)
@@ -452,7 +455,7 @@ var file_teleport_lib_teleterm_vnet_v1_vnet_service_proto_rawDesc = []byte{
0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e,
0x76, 0x31, 0x2e, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74, 0x65,
0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2a,
0xe1, 0x01, 0x0a, 0x14, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74,
0x8b, 0x02, 0x0a, 0x14, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74,
0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x0a, 0x22, 0x42, 0x41, 0x43, 0x4b,
0x47, 0x52, 0x4f, 0x55, 0x4e, 0x44, 0x5f, 0x49, 0x54, 0x45, 0x4d, 0x5f, 0x53, 0x54, 0x41, 0x54,
0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00,
@@ -466,43 +469,46 @@ var file_teleport_lib_teleterm_vnet_v1_vnet_service_proto_rawDesc = []byte{
0x45, 0x53, 0x5f, 0x41, 0x50, 0x50, 0x52, 0x4f, 0x56, 0x41, 0x4c, 0x10, 0x03, 0x12, 0x24, 0x0a,
0x20, 0x42, 0x41, 0x43, 0x4b, 0x47, 0x52, 0x4f, 0x55, 0x4e, 0x44, 0x5f, 0x49, 0x54, 0x45, 0x4d,
0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e,
0x44, 0x10, 0x04, 0x32, 0xe6, 0x03, 0x0a, 0x0b, 0x56, 0x6e, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x62, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x2b, 0x2e, 0x74,
0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61,
0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x74, 0x65, 0x6c, 0x65,
0x44, 0x10, 0x04, 0x12, 0x28, 0x0a, 0x24, 0x42, 0x41, 0x43, 0x4b, 0x47, 0x52, 0x4f, 0x55, 0x4e,
0x44, 0x5f, 0x49, 0x54, 0x45, 0x4d, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4e, 0x4f,
0x54, 0x5f, 0x53, 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x05, 0x32, 0xe6, 0x03,
0x0a, 0x0b, 0x56, 0x6e, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a,
0x05, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x2b, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72,
0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76,
0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c,
0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74,
0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x5f, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x2a, 0x2e, 0x74, 0x65, 0x6c, 0x65,
0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72,
0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12,
0x2a, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e,
0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x74, 0x65,
0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x70,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x77, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74,
0x44, 0x4e, 0x53, 0x5a, 0x6f, 0x6e, 0x65, 0x73, 0x12, 0x32, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70,
0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d,
0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x4e, 0x53,
0x5a, 0x6f, 0x6e, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x74,
0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73,
0x74, 0x44, 0x4e, 0x53, 0x5a, 0x6f, 0x6e, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x98, 0x01, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f,
0x75, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3d, 0x2e,
0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65,
0x74, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3e, 0x2e, 0x74,
0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74,
0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x55, 0x5a, 0x53,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72,
0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x74,
0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x74, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x72, 0x6d, 0x2f, 0x76, 0x6e, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x6e, 0x65,
0x74, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74,
0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e,
0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x77, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x4e, 0x53, 0x5a, 0x6f, 0x6e,
0x65, 0x73, 0x12, 0x32, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x6c, 0x69,
0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76, 0x6e, 0x65, 0x74, 0x2e,
0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x4e, 0x53, 0x5a, 0x6f, 0x6e, 0x65, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72,
0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76,
0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x4e, 0x53, 0x5a, 0x6f,
0x6e, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x98, 0x01, 0x0a, 0x17,
0x47, 0x65, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74, 0x65,
0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3d, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f,
0x72, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e,
0x76, 0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x67,
0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3e, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72,
0x74, 0x2e, 0x6c, 0x69, 0x62, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2e, 0x76,
0x6e, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72,
0x6f, 0x75, 0x6e, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x55, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x61, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x61, 0x6c, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x70, 0x6f, 0x72,
0x74, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x74, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x2f, 0x76,
0x6e, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x6e, 0x65, 0x74, 0x76, 0x31, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -125,7 +125,11 @@ export enum BackgroundItemStatus {
/**
* @generated from protobuf enum value: BACKGROUND_ITEM_STATUS_NOT_FOUND = 4;
*/
NOT_FOUND = 4
NOT_FOUND = 4,
/**
* @generated from protobuf enum value: BACKGROUND_ITEM_STATUS_NOT_SUPPORTED = 5;
*/
NOT_SUPPORTED = 5
}
// @generated message type with reflection information, may provide speed optimized methods
class StartRequest$Type extends MessageType<StartRequest> {
+2 -6
View File
@@ -21,20 +21,14 @@ package vnet
import (
"context"
"os"
"github.com/gravitational/trace"
api "github.com/gravitational/teleport/gen/proto/go/teleport/lib/teleterm/vnet/v1"
"github.com/gravitational/teleport/lib/vnet"
vnetdaemon "github.com/gravitational/teleport/lib/vnet/daemon"
)
func (s *Service) GetBackgroundItemStatus(ctx context.Context, req *api.GetBackgroundItemStatusRequest) (*api.GetBackgroundItemStatusResponse, error) {
if os.Getenv(vnet.EnvFeatureFlag) != "yes" {
return nil, trace.NotImplemented("tsh was built with VNet daemon support, but the feature flag is not enabled")
}
status, err := vnetdaemon.DaemonStatus()
if err != nil {
return nil, trace.Wrap(err)
@@ -55,6 +49,8 @@ func backgroundItemStatusFromServiceStatus(status vnetdaemon.ServiceStatus) api.
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_REQUIRES_APPROVAL
case vnetdaemon.ServiceStatusNotFound:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_FOUND
case vnetdaemon.ServiceStatusNotSupported:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_NOT_SUPPORTED
default:
return api.BackgroundItemStatus_BACKGROUND_ITEM_STATUS_UNSPECIFIED
}
+4
View File
@@ -200,6 +200,8 @@ const (
ServiceStatusEnabled ServiceStatus = 1
ServiceStatusRequiresApproval ServiceStatus = 2
ServiceStatusNotFound ServiceStatus = 3
// ServiceStatusNotSupported is returned by us when macOS version is < 13.0.
ServiceStatusNotSupported ServiceStatus = -1
)
func (s ServiceStatus) String() string {
@@ -212,6 +214,8 @@ func (s ServiceStatus) String() string {
return "requires approval"
case ServiceStatusNotFound:
return "not found"
case ServiceStatusNotSupported:
return "not supported"
default:
return strconv.Itoa(int(s))
}
+1 -9
View File
@@ -21,22 +21,14 @@ package vnet
import (
"context"
"os"
"github.com/gravitational/trace"
"github.com/gravitational/teleport/lib/vnet/daemon"
)
const EnvFeatureFlag = "VNETDAEMON"
func execAdminProcess(ctx context.Context, config daemon.Config) error {
// TODO(ravicious): Remove the feature env var after the daemon gets implemented.
if os.Getenv(EnvFeatureFlag) == "yes" {
return trace.Wrap(daemon.RegisterAndCall(ctx, config))
}
return trace.Wrap(execAdminSubcommand(ctx, config))
return trace.Wrap(daemon.RegisterAndCall(ctx, config))
}
func DaemonSubcommand(ctx context.Context) error {
@@ -80,4 +80,5 @@ enum BackgroundItemStatus {
BACKGROUND_ITEM_STATUS_ENABLED = 2;
BACKGROUND_ITEM_STATUS_REQUIRES_APPROVAL = 3;
BACKGROUND_ITEM_STATUS_NOT_FOUND = 4;
BACKGROUND_ITEM_STATUS_NOT_SUPPORTED = 5;
}
+43
View File
@@ -0,0 +1,43 @@
// Teleport
// Copyright (C) 2024 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//go:build vnetdaemon
// +build vnetdaemon
package common
import (
"log/slog"
"github.com/gravitational/trace"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/teleport/lib/vnet"
)
func (c *vnetDaemonCommand) run(cf *CLIConf) error {
if cf.Debug {
utils.InitLogger(utils.LoggingForDaemon, slog.LevelDebug)
} else {
utils.InitLogger(utils.LoggingForDaemon, slog.LevelInfo)
}
return trace.Wrap(vnet.DaemonSubcommand(cf.Context))
}
func (c *vnetAdminSetupCommand) run(cf *CLIConf) error {
return trace.NotImplemented("tsh was built with support for VNet daemon, use %s instead", vnetDaemonSubCommand)
}
+3 -38
View File
@@ -21,17 +21,12 @@ package common
import (
"fmt"
"log/slog"
"os"
"github.com/alecthomas/kingpin/v2"
"github.com/gravitational/trace"
"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/teleport/lib/vnet"
"github.com/gravitational/teleport/lib/vnet/daemon"
)
type vnetCommand struct {
@@ -100,28 +95,6 @@ func newVnetAdminSetupCommand(app *kingpin.Application) *vnetAdminSetupCommand {
return cmd
}
func (c *vnetAdminSetupCommand) run(cf *CLIConf) error {
homePath := os.Getenv(types.HomeEnvVar)
if homePath == "" {
// This runs as root so we need to be configured with the user's home path.
return trace.BadParameter("%s must be set", types.HomeEnvVar)
}
config := daemon.Config{
SocketPath: c.socketPath,
IPv6Prefix: c.ipv6Prefix,
DNSAddr: c.dnsAddr,
HomePath: homePath,
ClientCred: daemon.ClientCred{
Valid: true,
Egid: c.egid,
Euid: c.euid,
},
}
return trace.Wrap(vnet.AdminSetup(cf.Context, config))
}
type vnetDaemonCommand struct {
*kingpin.CmdClause
// Launch daemons added through SMAppService are launched from a static .plist file, hence
@@ -131,17 +104,9 @@ type vnetDaemonCommand struct {
func newVnetDaemonCommand(app *kingpin.Application) *vnetDaemonCommand {
return &vnetDaemonCommand{
// The command must match the command provided in the .plist file.
CmdClause: app.Command("vnet-daemon", "Start the VNet daemon").Hidden(),
CmdClause: app.Command(vnetDaemonSubCommand, "Start the VNet daemon").Hidden(),
}
}
func (c *vnetDaemonCommand) run(cf *CLIConf) error {
if cf.Debug {
utils.InitLogger(utils.LoggingForDaemon, slog.LevelDebug)
} else {
utils.InitLogger(utils.LoggingForDaemon, slog.LevelInfo)
}
return trace.Wrap(vnet.DaemonSubcommand(cf.Context))
}
// The command must match the command provided in the .plist file.
const vnetDaemonSubCommand = "vnet-daemon"
+56
View File
@@ -0,0 +1,56 @@
// Teleport
// Copyright (C) 2024 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//go:build !vnetdaemon
// +build !vnetdaemon
package common
import (
"os"
"github.com/gravitational/trace"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/lib/vnet"
"github.com/gravitational/teleport/lib/vnet/daemon"
)
func (c *vnetDaemonCommand) run(cf *CLIConf) error {
return trace.NotImplemented("tsh was built without support for VNet daemon")
}
func (c *vnetAdminSetupCommand) run(cf *CLIConf) error {
homePath := os.Getenv(types.HomeEnvVar)
if homePath == "" {
// This runs as root so we need to be configured with the user's home path.
return trace.BadParameter("%s must be set", types.HomeEnvVar)
}
config := daemon.Config{
SocketPath: c.socketPath,
IPv6Prefix: c.ipv6Prefix,
DNSAddr: c.dnsAddr,
HomePath: homePath,
ClientCred: daemon.ClientCred{
Valid: true,
Egid: c.egid,
Euid: c.euid,
},
}
return trace.Wrap(vnet.AdminSetup(cf.Context, config))
}
@@ -188,9 +188,6 @@ export default class MainProcess {
env: {
...process.env,
TELEPORT_HOME: homeDir,
VNETDAEMON: this.configService.get('feature.vnetDaemon').value
? 'yes'
: undefined,
},
}
);
@@ -131,10 +131,6 @@ export const createAppConfigSchema = (platform: Platform) => {
.boolean()
.default(false)
.describe('Disables SSH connection resumption.'),
'feature.vnetDaemon': z
.boolean()
.default(false)
.describe('Use daemon instead of osascript for VNet'),
});
};
@@ -207,7 +207,11 @@ const notifyAboutDaemonBackgroundItem = async (ctx: IAppContext) => {
throw error;
}
if (backgroundItemStatus === BackgroundItemStatus.ENABLED) {
if (
backgroundItemStatus === BackgroundItemStatus.ENABLED ||
backgroundItemStatus === BackgroundItemStatus.NOT_SUPPORTED ||
backgroundItemStatus === BackgroundItemStatus.UNSPECIFIED
) {
return;
}