backend/session/freebsd: Fix the way to get TTY path
requested to merge github/fork/lantw44/wip/lantw/backend-session-freebsd-Fix-the-way-to-get-TTY-path into master
Previously, the path of TTY is generated using snprintf with %d format. It works with TTY 1 to 10, but fails with TTY with greater number because the number used in the name is in base 32 instead of base 10. Since there is no standard function to convert a number to a string with a custom base, this commit adds a function to do it.