postfix寄信認證改用dovecot

一直以來我都讓postfix使用 sasl 方式處裡寄信認證, 但是連結到多網域主控伺服器的時候, 就會出錯, 很麻煩.
經過測試 dovecot 可以使用多組 userdb , 與passdb , 達到一個mail server 支援多個ldap網域主控.

當然也能省下一個sasl的service

  • 修改dovecort的 conf.d/10-master.conf
service auth {
...
  unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    # Assuming the default Postfix user and group
    user = postfix
    group = postfix
  }
  ...
}

#以下設定為了相容outlook系統
auth_mechanisms = plain login
  • 修改postfix的main.cf
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

# On Debian Wheezy path must be relative and queue_directory defined
#queue_directory = /var/spool/postfix

# and the common settings to enable SASL:
smtpd_sasl_auth_enable = yes
  • 修改postfix的master.cf
submission inet n - n - - smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_sasl_security_options=noanonymous
  -o smtpd_sasl_local_domain=$myhostname
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o smtpd_sender_login_maps=hash:/etc/postfix/virtual
  -o smtpd_sender_restrictions=reject_sender_login_mismatch
 ...

參考:

https://doc.dovecot.org/configuration_manual/howto/postfix_and_dovecot_sasl/

移除windows 10或以後版本,路徑檔案超過260個字元

這真是很令人頭疼的問題, 預設是不能超過260個字元, 微軟說windows 10 1607版本後面,可以自行調整開啟長檔名的功能

從 Windows 10 1607 版開始,已從一般 Win32 檔案和目錄函式中移除MAX_PATH限制。 不過,您必須加入宣告新的行為
  • 個人主機

修改reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001

或是改本機原則

Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths
  • 公司主機(網域主控群組原則)
  1. AD: windows 2012R2或之前的才需要這樣做
  2. 安裝最新版windows 10 管理範本
    https://www.microsoft.com/en-us/download/103124
  3. 將windows 10管理範本複製到目前網域的群組原則
    複製  C:\Program Files (x86)\Microsoft Group Policy\Windows 10 and Windows Server 2016\PolicyDefinitions

    SYSVOL\domain\Policies\PolicyDefinitions
  4. 重新執行群組原則設定, 就能看到 Enable win32 long paths

android kotlin coroutines

import kotlinx.coroutines.*
fun main() {
   repeat(3) {
        GlobalScope.launch {
            println("Hi from ${Thread.currentThread()}")
        }
    }
}
  • 非同步
import kotlinx.coroutines.*
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

val formatter = DateTimeFormatter.ISO_LOCAL_TIME
val time = { formatter.format(LocalDateTime.now()) }

suspend fun getValue(): Double {
    println("entering getValue() at ${time()}")
    delay(3000)
    println("leaving getValue() at ${time()}")
    return Math.random()
}

fun main() {
    runBlocking {
        val num1 = getValue()
        val num2 = getValue()
        println("result of num1 + num2 is ${num1 + num2}")
    }
}

同步

import kotlinx.coroutines.*
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

val formatter = DateTimeFormatter.ISO_LOCAL_TIME
val time = { formatter.format(LocalDateTime.now()) }

suspend fun getValue(): Double {
    println("entering getValue() at ${time()}")
    delay(3000)
    println("leaving getValue() at ${time()}")
    return Math.random()
}

fun main() {
    runBlocking {
        val num1 = async { getValue() }
        val num2 = async { getValue() }
        println("result of num1 + num2 is ${num1.await() + num2.await()}")
    }
}

job

val job: Job = GlobalScope.launch(Dispatchers.Main) {
    // launch coroutine in the main thread
    for (i in 10 downTo 1) { // countdown from 10 to 1
        textView.text = "count down $i ..." // update text
        delay(1000) // wait half a second
    }
    textView.text = "Done!"
}
job.cancel()

android kotlin viewBinding 新做法

寫android總是寫不好, 之前取得view要使用findViewByI的方式, 過了一段時間回頭看, 現在又改了改成使用viewBinding 說是比較快…

  • gradle(module)
buildFeatures {
    viewBinding = true
}
  • main activity
class MainActivity : AppCompatActivity() {

    lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
    }
}
  • 使用方式變簡單了
// 舊版
val myButton: Button = findViewById(R.id.my_button)
myButton.text = "A button"

// 新版
val myButton: Button = binding.myButton
myButton.text = "A button"

// Best way with view binding and no extra variable
binding.myButton.text = "A button"

windows 10列出usb連線裝置

我們外接usb裝置, 例如印表機, 讀卡機, 常常讀取失敗,也導致常常要換另外的usb孔測試

因此就需要這個軟體, 列出曾經連線過的usb裝置資訊, 必要時解除安裝其驅動程式,再重新安裝即可

https://www.nirsoft.net/utils/usb_devices_view.html

使用時請務必確認usb裝置未連接到主機

https://www.nirsoft.net/utils/usb_log_view.html

這個網站還有很多奇耙好用的小工具軟體

https://www.nirsoft.net

1 ... 16 17 18 19 20 ... 75