Horde shared mailboxes - dovecot

I'm trying to set up one mailbox to be shared with another one using steps described here but for some reason I do not see that option in my mailbox (logged as an admin) even I have set ACL as a true in the IMP configuration.
From dovecot -n:
auth_debug = yes
auth_debug_passwords = yes
auth_master_user_separator = *
auth_mechanisms = plain login
auth_verbose = yes
auth_verbose_passwords = yes
dict {
acl = mysql:/usr/etc/dovecot/dovecot-dict-sql.conf.ext
}
disable_plaintext_auth = no
lda_mailbox_autosubscribe = yes
log_path = /var/log/dovecot.log
mail_home = mdbox:/mnt/homedirs/%2Mu/%2.2Mu/%u
mail_location = mdbox:/mnt/mailboxes/%2Mu/%2.2Mu/%u
mail_plugins = acl
mail_shared_explicit_inbox = yes
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext vnd.dovecot.pipe vnd.dovecot.filter vnd.dovecot.execute
namespace {
list = children
location = mdbox:/mnt/mailboxes/%%2Mu/%%2.2Mu/%%u
prefix = shared/%%u/
separator = /
subscriptions = yes
type = shared
}
namespace inbox {
inbox = yes
location =
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox INBOX {
auto = subscribe
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
prefix =
separator = /
subscriptions = yes
}
passdb {
args = /usr/etc/dovecot/mastership-sql.conf
driver = sql
master = yes
pass = yes
}
passdb {
args = /usr/etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
plugin {
acl = vfile
acl_defaults_from_inbox = yes
acl_shared_dict = proxy::acl
sieve_execute_socket_dir = sieve-execute
sieve_extensions = +vnd.dovecot.execute +vnd.dovecot.filter +vnd.dovecot.pipe
sieve_filter_socket_dir = sieve-filter
sieve_pipe_socket_dir = sieve-pipe
sieve_plugins = sieve_extprograms
}
service dict {
unix_listener dict {
user = dovecot
}
}
service imap-postlogin {
executable = script-login /usr/etc/dovecot/imappostlogin
user = $default_internal_user
}
service imap {
executable = imap imap-postlogin
}
ssl = no
ssl_cert = </etc/pki/tls/certs/hostname.bundle
userdb {
args = uid=dovecot gid=dovecot home=/mnt/mailboxes/%%2Mu/%%2.2Mu/%%u
driver = static
}
protocol lmtp {
mail_plugins = acl sieve
}
protocol lda {
mail_plugins = acl sieve
}
protocol imap {
mail_plugins = acl imap_acl
}
Any tips on that?

It came up that for some reason backends.local.php shouldn't be a modified copy of backends.php. Simple - avoid default array notification for config but rather to set it as
<?php
$servers['imap']['disabled'] = true;
$servers['advanced']['disabled'] = false;
$servers['advanced']['secure'] = 'tls';
$servers['advanced']['debug'] = '/tmp/imp_imap.log';
$servers['advanced']['debug_raw'] = true;

Related

Terraforms to create Azure API Management Private Endpoint

I'm trying to script creation of an Azure API Management having a Private Endpoint within a VNET Subnet.
I'm able to create it manually no problem in Azure Portal, but can't quite figure out the terraform script.
The VNET and Subnet are created in a separate process, so they are not in the Terraform script but for the API Management piece I have:
resource "azurerm_api_management" "app" {
location = var.the_location
resource_group_name = "${var.the_resource_group}"
name = "${var.the_prefix}-api-mgmt"
publisher_email = var.api_mgmt_publisher_email
publisher_name = var.api_mgmt_publisher_name
sku_name = "${var.api_mgmt_sku}_1"
tags = var.resource_tags }
resource "azurerm_private_endpoint" "endpoint" {
name = "${var.the_prefix}-api-privateendpoint"
location = var.the_location
resource_group_name = var.the_resource_group
subnet_id = var.subnetId
tags = var.resource_tags
private_service_connection {
name = "api-privateserviceconnection"
private_connection_resource_id = azurerm_api_management.app.id
is_manual_connection = false
subresource_names = [] }}
The var.subnetId is the full id of the subnet ie.
/subscriptions/{subscriptionId}/resourceGroups/OpenEHR/providers/Microsoft.Network/virtualNetworks/OpenEHR-VNET/subnets/API-Subnet
The error I get is
Error: creating Private Endpoint "i365sabppdsdevtb-api-privateendpoint" (Resource Group "i365-uks-ehsabppds-devtb-rg"): network.PrivateEndpointsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="MissingParameterOnPrivateLinkServiceConnection" Message="Private link service connection /subscriptions/8cb2b2d3-9411-46e4-926d-22d6378349bc/resourceGroups/i365-uks-ehsabppds-devtb-rg/providers/Microsoft.Network/privateEndpoints/i365sabppdsdevtb-api-privateendpoint/privateLinkServiceConnections/api-privateserviceconnection is missing required parameter 'group Id'." Details=[]
I think the error is something to so with subresource_names but I can't work out what to put in there.
I tried [ "sites" ] but then I get the error:
│ Error: creating Private Endpoint "i365sabppdsdevtb-api-privateendpoint" (Resource Group "i365-uks-ehsabppds-devtb-rg"): network.PrivateEndpointsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="PrivateEndpointBadRequest" Message="Call to Microsoft.ApiManagement/service failed. Error message: The Request has invalid groupId sites." Details=[]
Any ideas, much appreciated.
Thanks.
Issue was caused because of the private service connection resource id and sub resource names. Please use below configuration
private_connection_resource_id = azurerm_api_management.app.id
subresource_names = ["Gateway"]
Find below code snippets for references
Step1:
Copy below code from main tf file.
provider "azurerm" {
features {}
}
variable "prefix" {
default = "rg_swar"
}
resource "azurerm_resource_group" "example" {
name = "rg_swar-resources"
location = "West Europe"
}
resource "azurerm_virtual_network" "example" {
name = "example-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_subnet" "service" {
name = "service"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.1.0/24"]
enforce_private_link_service_network_policies = true
}
resource "azurerm_subnet" "endpoint" {
name = "endpoint"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.2.0/24"]
enforce_private_link_endpoint_network_policies = true
}
resource "azurerm_public_ip" "example" {
name = "example-pip"
sku = "Standard"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
allocation_method = "Static"
}
resource "azurerm_lb" "example" {
name = "example-lb"
sku = "Standard"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
frontend_ip_configuration {
name = azurerm_public_ip.example.name
public_ip_address_id = azurerm_public_ip.example.id
}
}
resource "azurerm_private_link_service" "example" {
name = "example-privatelink"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
nat_ip_configuration {
name = azurerm_public_ip.example.name
primary = true
subnet_id = azurerm_subnet.service.id
}
load_balancer_frontend_ip_configuration_ids = [
azurerm_lb.example.frontend_ip_configuration.0.id,
]
}
resource "azurerm_api_management" "app" {
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
name = "swar-api-mgmt"
publisher_email = "test#demo.com"
publisher_name = "Swarna Demo"
sku_name = "Developer_1"
//tags = var.resource_tags
}
resource "azurerm_private_endpoint" "example" {
name = "example-endpoint"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
subnet_id = azurerm_subnet.endpoint.id
private_service_connection {
name = "example-privateserviceconnection"
//private_connection_resource_id = azurerm_private_link_service.example.id
private_connection_resource_id = azurerm_api_management.app.id
subresource_names = ["Gateway"]
is_manual_connection = false
}
}
Step2:
run below commands
terraform plan
terraform apply -auto-approve
Review:
Above code snippet will host the services into Azure Portal.
Hope this helps!

Unable to update firewall rules for mysqlserver from app service

I am trying to update vnet rules for mysqlserver from app service.
App Service and mysqlserver tf code is like below:
module "app_service" {
for_each = coalesce(var.app_service, {})
source = "company/org/app-service/azurerm"
version = "1.1"
location = var.environment_hosting_region
resource_group_name = var.environment_resource_groups
tags = try(each.value.tags, local.tags)
name = try(each.value.name, null)
}
variable "mysqlserver" {
description = "Map of mysqlserver objects"
type = any
default = null
}
module "mysqlserver" {
for_each = coalesce(var.mysqlserver, {})
source = "company/org/mysqlserver/azurerm"
version = "1.1"
administrator_login = try(each.value.administrator_login, null)
administrator_login_password = try(each.value.administrator_login_password, null)
backup_retention_days = try(each.value.backup_retention_days, null)
charset = try(each.value.charset, "utf8")
collation = try(each.value.collation, "utf8_unicode_ci")
create_mode = try(each.value.create_mode, "Default")
creation_source_server_id = try(each.value.creation_source_server_id, null)
database_names = try(each.value.database_names, [])
default_rules = try(each.value.default_rules, true)
enable_account_admins = try(each.value.enable_account_admins, true)
enable_threat_detection_policy = try(each.value.enable_threat_detection_policy, true)
geo_redundant_backup = try(each.value.geo_redundant_backup, false)
identity_type = try(each.value.identity_type, null)
location = var..environment_hosting_region
mysql_version = try(each.value.mysql_version, null)
name = try(each.value.name, null)
resource_group_name = var..environment_resource_groups
restore_point_in_time = try(each.value.restore_point_in_time, null)
sku_name = try(each.value.sku_name, null)
storage_mb = try(each.value.storage_mb, null)
tags = try(each.value.tags, local.tags)
threat_log_retention_days = try(each.value.threat_log_retention_days, 7)
vnet_rules = [for subnet in try(each.value.subnet_ref, []) : data.azurerm_subnet.subnet[subnet].id]
nsg_rules = try(each.value.nsg_rules, [])
firewall_rules = each.value.app_service_ref != null ? module.app_service[each.value.app_service_ref].firewall_rules : null
}
I get multiple errors as like below:
│ Error: waiting for create/update of Firewall Rule: (Name "rule_x.y.z.170" / Server Name "u2zuuhjjsddm002" / Resource Group "mysqlserver-rg"): Code="InvalidParameterValue" Message="Invalid value given for parameter
'{0}'. Specify a valid parameter value."
│
│ with module.mysqlserver["patterns_default_mysqlserver"].azurerm_mysql_firewall_rule.firewall_rules[53],
│ on .terraform/modules/mysqlserver/main.tf line 69, in resource "azurerm_mysql_firewall_rule" "firewall_rules":
│ 69: resource "azurerm_mysql_firewall_rule" "firewall_rules" {
Mysqlserver module code as per below:
main.tf
locals {
firewall_rules = concat(local.tfe_firewall.tfe_servers, local.default_fw_rules, var.firewall_rules)
}
resource "azurerm_mysql_server" "mysql" {
name = var.name
resource_group_name = var.resource_group_name
ssl_enforcement_enabled = true
ssl_minimal_tls_version_enforced = "TLS1_2"
dynamic "identity" {
for_each = var.identity_type != null ? [""] : []
content {
type = var.identity_type
}
}
threat_detection_policy {
enabled = var.enable_threat_detection_policy
email_account_admins = var.enable_account_admins
retention_days = var.threat_log_retention_days
}
tags = var.tags
}
resource "azurerm_mysql_database" "databases" {
count = length(var.database_names)
name = element(var.database_names, count.index)
resource_group_name = var.resource_group_name
server_name = azurerm_mysql_server.mysql.name
charset = var.charset
collation = var.collation
}
resource "azurerm_mysql_virtual_network_rule" "subnets" {
count = length(var.vnet_rules)
name = "subnet-${count.index}"
resource_group_name = var.resource_group_name
server_name = azurerm_mysql_server.mysql.name
subnet_id = element(var.vnet_rules, count.index)
}
resource "azurerm_network_security_rule" "mysql-nsg" {
count = length(var.nsg_rules)
name = "NSG-MYSQL-${count.index}"
priority = 200+count.index
direction = "Outbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "3306"
source_address_prefix = var.nsg_rules[count.index]["source_address_prefix"]
destination_address_prefix = "Sql"
resource_group_name = var.resource_group_name
network_security_group_name = var.nsg_rules[count.index]["network_security_group_name"]
}
resource "azurerm_mysql_firewall_rule" "firewall_rules" {
count = local.firewall_rules == [] ? 0 : length(local.firewall_rules)
name = local.firewall_rules[count.index]["name"]
resource_group_name = var.resource_group_name
server_name = azurerm_mysql_server.mysql.name
start_ip_address = local.firewall_rules[count.index]["start_ip_address"]
end_ip_address = local.firewall_rules[count.index]["end_ip_address"]
depends_on = [
azurerm_mysql_server.mysql
]
}
variables.tf
variable "firewall_rules" {
description = "List of firewall rules to be attached to the MySQL server."
type = list(object({
name = string
start_ip_address = string
end_ip_address = string
}))
default = []
}
variable "nsg_rules" {
description = "NSG Rules"
type = list(object({
source_address_prefix = string
network_security_group_name = string
}))
default = []
}
variable "vnet_rules" {
description = "List of subnets to add to vnet_rules"
type = list(string)
default = []
}
variable "charset" {
description = "Specifies the Charset for the MySQL Database, which needs to be a valid MySQL Charset. Available option are (https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html)."
type = string
default = "utf8"
}
variable "collation" {
description = "Specifies the Collation for the MySQL Database, which needs to be a valid MySQL Collation. Available option are (https://dev.mysql.com/doc/refman/5.7/en/charset-mysql.html)."
type = string
default = "utf8_unicode_ci"
}
variable "default_rules" {
description = "Variable to control whether to turn on default rules"
type = bool
default = true
}
Unable to understand what is the issue and how can it be resolved.
Any guidance shall be much appreciated.

how to replace part of object in Terraform

I'm constructing some objects to store the required information in Terraform
I just defined a variable and its value as below
vnetsettings = {
HUBVNET = {
VNET_Name = "co-vnet-01"
VNET_Location = "eastasia"
VNET_Resource_Group = "CoreInfra"
VNET_Address_Space = ["10.1.0.0/16","10.2.0.0/16"]
VNET_Tags = {
env = "prod"
application = "hub"
}
VNET_DNS_Servers = ["10.1.0.4","10.2.0.4"]
}
MGMTVNET = {
VNET_Name = "mgmt-vnet-01"
VNET_Location = "eastasia"
VNET_Resource_Group = "MGMT"
VNET_Address_Space = ["10.3.0.0/16","10.4.0.0/16"]
VNET_Tags = {
env = "prod"
application = "MGMT"
}
VNET_DNS_Servers = ["10.1.0.4","10.2.0.4"]
}
}
my question is how can i bulk replace some of the attributes in the object, like VNET_Resource_Group
below is the result i want, everything same as the one above, except for the VNET_Resource_Group
vnetsettings = {
HUBVNET = {
VNET_Name = "co-vnet-01"
VNET_Location = "eastasia"
VNET_Resource_Group = "replacedvalue"
VNET_Address_Space = ["10.1.0.0/16","10.2.0.0/16"]
VNET_Tags = {
env = "prod"
application = "hub"
}
VNET_DNS_Servers = ["10.1.0.4","10.2.0.4"]
}
MGMTVNET = {
VNET_Name = "mgmt-vnet-01"
VNET_Location = "eastasia"
VNET_Resource_Group = "replacedvalue"
VNET_Address_Space = ["10.3.0.0/16","10.4.0.0/16"]
VNET_Tags = {
env = "prod"
application = "MGMT"
}
VNET_DNS_Servers = ["10.1.0.4","10.2.0.4"]
}
}
What you can do is to create a local variable which is essentially a copy of the original object. Also, while making the copy you can replace an attribute from the original objects using the merge function.
locals {
vnetsettings_updated = {
for key, value in var.vnetsettings : key => merge(value, { VNET_Resource_Group = "replacedvalue" })
}
}
# Example usage of the updated object
output "vnetsettings" {
description = "VNET settings with updated VNET_Resource_Group"
value = local.vnetsettings_updated
}

Add custom DNS Server IP to an Azure VM NIC using Terraform

How to point to custom DNS IP using terraform IP Configuration block, sample code show below, is this valid?
resource "azurerm_network_interface" "example" {
name = "example-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
dns_servers = 8.8.8.8,8.8,8.8
}
}
as per terraform documentation
resource "azurerm_network_interface" "example" {
name = "example-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
dns_servers = ["8.8.8.8","1.1.1.1"]
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
}
}

Parse Bloomberg API response to JSON in python3

How can I convert the response message that returned from using bloomberg API in (python3 and flask) in to JSON
here is a response example:
ReferenceDataResponse = {
securityData[] = {
securityData = {
security = "FB EQUITY"
eidData[] = {
}
fieldExceptions[] = {
}
sequenceNumber = 0
fieldData = {
PX_LAST = 186.270000
VOLUME = 16746904.000000
}
}
securityData = {
security = "IBM EQUITY"
eidData[] = {
}
fieldExceptions[] = {
}
sequenceNumber = 1
fieldData = {
PX_LAST = 134.400000
VOLUME = 2551009.000000
}
}
}
}
dealing with it with the comming piece of code :
if str(msg.messageType()) == "ReferenceDataResponse":
securities = msg.getElement('securityData')
securities_count = securities.numValues()
for i in range(securities_count):
security = securities.getValueAsElement(i)
ticker = security.getElementAsString('security')
if (security.hasElement('fieldData')):
fields = security.getElement('fieldData')
fields_count = fields.numElements()
for j in range (fields_count):
security_dict = None
field = fields.getElement(j)
f_name = field.name()
f_value = field.getValueAsString()
security_dict = {"ticker":ticker ,"f_name":f_name , "f_value":f_value}
bloom_data.append(security_dict)
give me (Object of type Name is not JSON serializable)
now, I cant not access the name object to reach the name of the fields
any help will be very appreciated
After a lot of search I found this doc that is very helpful for as a schema for using the bloomberg api for dealing with the response ....
Here's the link ==> api schema
example for handeling respnse using python3:
bloom_data = []
if str(msg.messageType()) == "ReferenceDataResponse":
securities = msg.getElement('securityData')
securities_count = securities.numValues()
for i in range(securities_count):
security = securities.getValueAsElement(i)
ticker = security.getElementAsString('security')
if (security.hasElement('fieldData')):
fields = security.getElement('fieldData')
fields_count = fields.numElements()
for j in range (fields_count):
security_dict = None
field = fields.getElement(j)
f_name = field.name()
f_value = field.getValueAsString()
security_dict = {"ticker":ticker ,"f_name":str(f_name) , "f_value":f_value}
bloom_data.append(security_dict)