Created attachment 177523 [details] the patch Currently, bsdinstall can help you select a wireless network from the list of the scanned ones. However, it doesn't allow you to configure a network that's not in the list manually. The attached patch attempts to fix this.
This looks reasonable, but I have not played with any of the wifi bits in bsdinstall
(In reply to Allan Jude from comment #1) If that matters, I tested the patch (and something around in case it breaks something), and nothing is broken.
Is fine to me. Someone please bug devin to triple verify and then please commit ASAP! - adrian
(In reply to Adrian Chadd from comment #3) Could you share the contacts of the people who might be interested?
In more than one place, please replace the following construct: case $? in 0) # many lines ;; *) exit 1 esac with the following, reducing the indentation of the primary block: [ $? -eq 0 ] || exit 1 # many lines The scripts/wlanconfig module includes "dialog.subr" which provides both f_dialog_noyes() and f_dialog_yesno() (depending on which you want to be the default choice). See "bsdconfig api dialog" for more information. Please change: dialog --backtitle "FreeBSD Installer" --title "Network Selection" --yesno "Do you want to select the network manually?" 0 0 Into the following: f_dialog_yesno "Do you want to select the network manually?" And there's no need to test $? exclusively, so instead of this: dialog ... [ $? -eq 0 ] || exit 1 You can instead simply say: f_dialog_yesno ... || exit 1 However, "exit" by default retains the status of the last command when not given a number, so in reality you can say this: f_dialog_yesno ... || exit And since the "||" is an "r-value seeking" operand, you can put the exit on a line of its own if you like for style: f_dialog_yesno "Do you want to select the network manually?" || exit # many lines That's the desired setup. The way you have it, everytime you call dialog, the following code is indented further and further, whereas I would like to see: f_dialog_yesno ... || exit # ... f_dialog_input ... || exit # ... f_dialog_input ... || exit Which brings us to the API for input dialog boxen. Use f_dialog_input() instead of "var=$( dialog ... --inputbox ... )". So instead of: NETWORK=`dialog --backtitle "FreeBSD Installer" --title "Network Selection" --inputbox "Enter SSID" 0 0 2>&1 1>&3` First of all, we don't use `...` but instead $(...) as the former is not nest-able. But instead of the above, we would use f_dialog_input() in the following way (see: bsdconfig api -dF 'f_dialog_input$'): f_dialog_title "Network Selection" f_dialog_input NETWORK "Enter SSID" || exit f_dialog_title_restore Which introduces how to set the title if/when necessary. Feel free to use it where most appropriate (e.g., before the f_dialog_yesno()). NOTE: It's important to utilize f_dialog_title()/f_dialog_title_restore() because some systems have backtitle and title reversed (and the API takes this into consideration with respect to which back-end system is in-use). The restore is not strictly necessary and is optional since scripts/wlanconfig runs in a discrete namespace, unshared with anything else (hence your ability to use "exit" without messing up the flow of bsdinstall). However, all those issues aside, you completely neglected thew new wlan API. See the following commands for required information: % bsdconfig api media/wlan # brief oversight of functions % bsdconfig api -da media/wlan | less -R # more verbose info You should add a line toward the top scripts/wlanconfig: f_include $BSDCFG_SHARE/media/wlan.subr See also: /usr/libexec/bsdconfig/120.networking/wlanconfig The bsdconfig wireless networking is much more advanced than, and is available to, bsdinstall's. Both have a "wlanconfig" module (e.g., see "bsdconfig wifi" or "bsdconfig wlan" or "bsdconfig wireless" -- all aliases to wlanconfig), but bsdconfig's is WAY more advanced than bsdinstall's. It's worth taking a look at bsdconfig's wlanconfig for inspiration, but more importantly, you can actually *use* the code there in the installer. Go ahead and steal code from bsdconfig to make bsdinstall better. I welcome that immensely ;D
(In reply to Devin Teske from comment #5) Dear Devin, Thank you so much for explaining this to me! However, I guess, the bsdconfig stuff doesn't match bsdinstall a bit. This might be just me, but the internal issue with that persists. However, I'm about to upload the new patch fixing the issues you've kindly noted to me.
Created attachment 177623 [details] the patch [2] the new patch, fixed.
Getting better. Now let's change the following in this stanza: ENCRYPTION=$(dialog --backtitle "FreeBSD Installer" --title "Network Selection" --menu "Select encryption type" 0 0 0 "WPA/WPA2 PSK" "" "WPA/WPA2 EAP" "" "WEP" "" "None" "" 2>&1 1>&3) 1. [FYI] FreeBSD's style in bsdinstall/bsdconfig is VAR=$([space]...[space]) not VAR=$(...) (just add space after the left-paren and before the right-paren) 2. You should defer the f_dialog_title_restore() call (do it later) so you can use $DIALOG_TITLE here to reduce duplication (e.g., --title "$DIALOG_TITLE") 3. With f_dialog_title_restore() done later, you can use $DIALOG_BACKTITLE as well (e.g., --backtitle "$DIALOG_BACKTITLE") 4. You've not used the internationalized attributes (e.g., --ok-label "$msg_ok" --cancel-label "$msg_cancel" (NB: $msg_ok and $msg_cancel are already set via API, i18n-friendly, and free of charge) NB: When you switched from invoking dialog(1) directly in your previous patch to using f_dialog_yesno() from the dialog API, you got i18n capabilities in that dialog for free (the Yes/No dialog will pick up alternate languages if loaded; e.g., it might say "Oui/Non" if LC_ALL=Fr_fr.ISO8859-1 and the French language files are loaded, which my friend Guillaume has, over @mozilla). 5. You've not calculated the optimum width/height for the list (relying on dialog to do this is faulty) 6. You're not supporting alternate dialog back-ends 7. Multiple menu items start with the letter W (preventing the user from utilizing the type-ahead ability in dialog(1) to highlight the item starting with unique letter, making it easier to select said item with space/enter) 8. You don't provide an "hline" to give the user a hint as to what keys are appropriate for interacting with the dialog (an example is given below where hline is in-use and adheres to i18n standards to allow alternate languages loaded) NB: I used $hline_arrows_tab_enter which is defined in the core i18n layer (/usr/libexec/bsdconfig/include/messages.subr[.$LC_ALL] is included by dialog.subr at the top of bsdinstall's scripts/wlanconfig so it's available for free; if you define your own value that is not already available, it should be added to the top of scripts/wlanconfig as a candidate for later inclusion into the core API) 9. You're assigning the direct result of your dialog invocation as the variable contents; a safer and more portable approach (taking many things into consideration) is to rely on a technique that involves defining you menu items separately and using the dialog API elements for mapping back the results (see below example). NB: Assigning your menu list to a variable allows you to do menu things within the dialog API already available to you. It's always a good approach to follow (again, see below; you can calculate the appropriate size of a dialog given said info). 10. You're redirecting stdout to a static file descriptor (3) when this information has been abstracted to a variable for you, should it ever be customized and/or changed. Use $DIALOG_TERMINAL_PASSTHRU_FD as is shown below. 11. You haven't loaded your menu into a function for convenience. There's a reason why dialog's --menu doesn't have an entry in the dialog API and that's because, well, I haven't sat down to write it yet but really, because it's pretty heady when dealing with. You'll see below that it works well in a function (for which the standard naming convention is "dialog_menu_*()". 12. You're not sanitizing the dialog response for spurious libc messages (see "bsdconfig api -dF sanitize" for more info) So here's what I would replace it with: dialog_menu_enctype() { local prompt="Select encryption type" local menu_list=" '1 WPA/WPA2 PSK' '' '2 WPA/WPA2 EAP' '' '3 WEP' '' '4 None '' " # END-QUOTE local hline="$hline_arrows_tab_enter" local height width rows eval f_dialog_menu_size height width rows \ \"\$DIALOG_TITLE\" \ \"\$DIALOG_BACKTITLE\" \ \"\$prompt\" \ \"\$hline\" \ $menu_list local menu_choice menu_choice=$( eval $DIALOG \ --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ --menu \"\$prompt\" \ $height $width $rows \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? f_dialog_menutag_sanitize menu_choice f_dialog_menutag_store -s "$menu_choice" return $retval } This also introduces a new API to use (a pair of functions, actually): f_dialog_menutag_store() and f_dialog_menutag_fetch() (see "bsdconfig api -dF _menutag_" for more info). Here's how the dialog_menu_enctype() function should be used: dialog_menu_enctype || exit f_dialog_menutag_fetch mtag case "$mtag" in *" WPA/WPA2 PSK") ... ;; *" WPA/WPA2 EAP") ... ;; *" WEP") ... ;; *" None") ... ;; esac Note how the case/esac uses * for the numerical prefix, allowing reorganization at a future date, if necessary. Continuing... It looks like the following was at the wrong indentation level: 1) # No exit 1 ;; And the "esac" on the very next line appears to be extra and undesired. -- Cheers, Devin
A little question: how do I make a memstick without a buildworld beforehand? See, buildworld takes around 7 hours on my machine, so it would be great to avoid it.
Created attachment 177635 [details] the patch [3] The fixed again patch
(In reply to Maxim Filimonov from comment #9) On Mac OS X, this is what I do to create a memstick: 1. Cmd+Space "terminal" Enter NOTE: Launches terminal irrespective of what app your in or what you're doing 2. time curl -LO download.freebsd.org/ftp/releases/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-amd64-memstick.img NOTE: Took 14m26s for me 3. curl -LO fraubsd.org/dl/WriteImage/Makefile 4. make 5. open -a WriteImage FreeBSD-11.0-RELEASE-amd64-memstick.img NOTE: This is like taking the .img, dragging it, and dropping it on WriteImage.app If I'm stopped by the "can't be opened ... unidentified developer" dialog: 5.a. sudo spctl --status 5.b. sudo spctl --master-disable 5.c. sudo spctl --status 5.d. repeat step 5 (and at some later time, --master-enable to turn signature checks back on) Then for the human bits: 6. Insert a blank thumb drive and follow the prompts Meanwhile, this is what I do on Windows: 1. Win+R "iexplore download.freebsd.org" ENTER 2. Navigate to releases/ISO-IMAGES/11.0/ 3. Right-click FreeBSD-11.0-RELEASE-amd64-memstick.img and select Save File As... or similar 4. Download win32diskimager from here if not installed https://sourceforge.net/projects/win32diskimager/ 5. Launch win32diskimager 6. Insert a USB image and select it 7. Select the button to write an image 8. Navigate to the downloaded .img, select it, and hit OK From there it's all magic. At the end of either process, you'll have a bootable USB memstick that has the OS on it and can be used as a LiveCD, installer, repair disk, or whatever. Cheers!
(In reply to Maxim Filimonov from comment #10) The following line: f_dialog_title "Network Selection" Belongs before the following line: f_dialog_yesno "Do you want to select the network manually?" (embodying the original patch's intent)
(In reply to Maxim Filimonov from comment #10) The following: ENCRYPTION=$( ... \ ... ) [ $? -eq 0 ] || exit 1 Should be instead: ENCRYPTION=$( ... \ ... ) || exit This is building upon: a. exit when not given a value, retains the previous status NOTE: This allows the [meaningful] exit status of dialog(1) to be exposed instead of being overwritten to one (1) b. The exit status of VAR=$( ... ) is the exit status of "..." in the sub-shell NOTE: This allows us to combine the VAR=$( ... ) and the exit-status test, ala VAR=$( ... ) || exit
(In reply to Maxim Filimonov from comment #10) You forgot a critical/required ";;" in the following: ... SCANSSID=1 f_dialog_title_restore break 3) # Rescan Which should appear as follows: ... SCANSSID=1 f_dialog_title_restore break ;; 3) # Rescan
(In reply to Devin Teske from comment #11) On Mac OS X, once the app has been authorized whilst spctl is disabled, re-enabling spctl is safe as the WriteImage application is now authorized, so future prompts are abated even if you re-enable spctl.
Just a general comment - it looks like we're taking the opportunity to refactor/tidy up the wifi side of this as well as adding the hidden ssid thing. I'd really like to see that work split into two pieces. Having a submitter be required to tidy up after someone elses previous attempt before they can commit two lines is a lot of work to ask for :) (And thank you Maxim for doing it!)
(In reply to Devin Teske from comment #11) Sorry, that was not the question. Let me explain it from a different angle. So I issued `make buildworld` once, thus the base system is basically all built and ready for `make memstick`. bsdinstall itself is written in shell, so we don't have to compile and link it. Where do I put the changed wlanconfig for `make memstick` to get it and put it onto the image? Is it put somewhere if I issue `make` or something in its directory?
Created attachment 177641 [details] the patch [4] Fixed the patch, now it should be ok
(In reply to Maxim Filimonov from comment #17) You can put your modified wlanconfig in /usr/libexec/bsdinstall/
(In reply to Devin Teske from comment #19) Sorry, but no. This way, the modified wlanconfig won't appear at the memstick.
(In reply to Maxim Filimonov from comment #20) The source file is /usr/src/usr.sbin/bsdinstall/scripts/wlanconfig If I recall correctly.
(In reply to Maxim Filimonov from comment #18) Looks great. Do you need me to commit it on your behalf?
(In reply to Devin Teske from comment #22) Yes please. If that's fine.
Erm, I hate to hurry anyone, but it's been a little while now.
*poke devin* :)
(In reply to Adrian Chadd from comment #25) I just lost my job of almost 3 years yesterday. Sorry about the delay. I will try to get it done as soon as possible.
oh damn, i'm sorry ;(
Sorry to hear that. Losing a job of 3 years sucks. I hope you get through it well.
A commit references this bug: Author: dteske Date: Thu Dec 8 16:41:18 UTC 2016 New revision: 309716 URL: https://svnweb.freebsd.org/changeset/base/309716 Log: Add support for "hidden" Wi-Fi networks PR: bin/214933 Submitted by: Maxim Filimonov <che@bein.link> Reviewed by: dteske, allanjude, adrian MFC after: 6 days X-MFC-with: Follow-up commit for style Changes: head/usr.sbin/bsdinstall/scripts/wlanconfig
The patch has been committed to the base system, so I'm closing the bug. Thank you everyone and merry Christmas or whatever you celebrate.
(In reply to Maxim Filimonov from comment #30) If you read the commit message (for r309716) to the base system, you'll see that there is an MFC and X-MFC-with request, which means you should not have closed the bug until the MFC was done. I am doing the MFC now.
A commit references this bug: Author: dteske Date: Sun Jan 8 16:56:00 UTC 2017 New revision: 311686 URL: https://svnweb.freebsd.org/changeset/base/311686 Log: MFC r309716: Add support for "hidden" Wi-Fi networks PR: bin/214933 Submitted by: Maxim Filimonov <che@bein.link> Reviewed by: dteske, allanjude, adrian Changes: _U stable/11/ stable/11/usr.sbin/bsdinstall/scripts/wlanconfig
A commit references this bug: Author: dteske Date: Sun Jan 8 18:14:22 UTC 2017 New revision: 311690 URL: https://svnweb.freebsd.org/changeset/base/311690 Log: MFC improvements to bsdinstall's wlanconfig module MFC [85] revisions 309719-309720, 309901-309902, 309904-309911, 309913-309920, 309922-309924, 309926, 309928, 309930, 309932, 309934, 309937-309942, 309944-309952, 309958-309998, and 310038 (described below) r309719: Remove unnecessary trailing backslashes r309720: Functions in their own section r309901: Comments r309902: Use $( ... ) instead of `...` r309904: Change "[ ! -z ... ]" => "[ ... ]" and "[ -z ... ]" => "[ ! ... ]" r309905: Remove unnecessary local initializers r309906: Consolidate locals r309907: Replace funny block with something easy to digest r309908: Collapse tiny if statements r309909: Change "[ ! ... ] && ..." to "[ ... ] || ..." r309910: Remove unnecessary quotes around number in test r309911: Group fallbacks together r309913: Allow $BSDINSTALL_TMPETC to contain whitespace or special chars r309914: Add missing `-e' parameter to sed invocations r309915: "echo | sed | sed | awk" is silly (changed to "echo | awk") r309916: Be internally consistent (": > ..." is used elsewhere in this file) r309917: awk(1) match() takes a regex, use /.../ to remind ourselves of this r309918: Remove unnecessary `-n' parameter to head/tail r309919: Whitespace r309920: Use provided API instead of hard-coded status integers r309922: Centralize backtitle string r309923: There is zero harm in always passing --default-item to dialog r309924: Always pass --default-item parameter to dialog r309926: Change the name of a variable from $def_item_... to $default_... r309928: Use ~ instead of match() r309930: Use ternary operator r309932: Remove an unnecessary "return $?" at end of function r309934: Consolidate redirects into here documents r309937: Whitespace (dialog options separated to minimize diffs) r309938: Use provided API (change "dialog" to "$DIALOG") r309939: Fix incorrect use of provided API r309940: Reorder dialog parameters based on commonality for readability r309941: Use provided API to centralize dialog title strings r309942: Allow the script path to contain whitespace and special characters r309944: Fix invalid parameter expansion (change $@ to "$@") r309945: 1 is the default descriptor for redirects without an fd prefix r309946: Use more succinct awk syntax r309947: Remove unnecessary semi-colons r309948: Remove incomplete and unnecessary creation of fd3 r309949: Utilize provided i18n strings r309950: Whitespace r309951: Remove an unnecessary call to f_dialog_title_restore() r309952: Move the secondary condition into the action clause r309958: Quote WLAN_IFACE (pedantic) r309959: Use oft-neglected syntax "startcondition, stopcondition { ... }" r309960: Add missing backslash r309961: Stop repeating strings (centralize prompt string) r309962: More efficiently make use of the exit status r309963: Avoid non-standard options r309964: Sort the domains r309965: Whitespace alignment r309966: Sanitize dialog output for portability/compatibility requirements r309967: Use more generic f_yesno() from provided API r309968: Properly quote variable r309969: Send stderr to the same place as stdout r309970: Remove completely unnecesary parentheses r309971: Start deconstructing a conveluted hunk of code r309972: If the first ping succeeded, why on Earth should we ping it again? r309973: Why use $? when you can use the command itself r309974: These two error messages have always been backwards since inception r309975: Continued resolution of conveluted statement r309976: You don't need parentheses for awk's printf r309977: Whitespace and alignment r309978: Neither printf nor print need parens in awk r309979: This statement has too many backslashes r309980: Just use print r309981: Add missing quotes r309982: Remove unnecessary quotes r309983: Use the provided API for calculating the appropriate size of menus r309984: Whitespace alignment r309985: Comment r309986: There's an API function for displaying errors r309987: There's an API function for displaying yes/no dialogs r309988: There's an API function for displaying pauses r309989: There's an API function for catching errors r309990: Calculate proper size of menu list dialog r309991: Simplify bringup of interface after changes and catch errors r309992: Restore previous comment r309993: Why test $? when you can test the command r309994: Wordsmithing r309995: Simplify loop by moving predicate to clause r309996: Simplify single-line if statements r309997: The flags of a WLAN need to be quoted r309998: It's completely pointless to replace newlines with space r310038: Revert r309918 -- modern POSIX has deprecated -<#>/+<#> syntax PR: bin/214933 Changes: _U stable/11/ stable/11/usr.sbin/bsdinstall/scripts/wlanconfig
(In reply to commit-hook from comment #29) SVN r311686 satisfies the MFC. SVN r311690 satisfies the X-MFC-with.