How do I append text to a /etc/… configuration file in NixOS? [closed] - config

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
Improve this question
[disclosure: I asked about this earlier on the NixOS channel but didn't get an answer after 30 minutes and it's a busy channel. If I get one there, I'll replicate it here]
I'm trying to add some lines to a configuration file in NixOS (for example /etc/pam.d/sudo). The configuration options available in pam.nix do not include the line I want to add (in this case, account requisite pam_time.so), and it does not include an extraConfig option either.
I know I can create new configuration files using environement.etc.filename.text so I went with that, but sudo nixos-rebuild switch then complains that it has two sources for the configuration file, the official one and mine (mismatched duplicate entry /nix/… <-> /nix/…):
environment.etc."pam.d/sudo".text = ''blah'';
Is there a general way to append to a /etc/ configuration file (or to patch it) in NixOS?
Or is the only way to modify the system .nix files (e.g. modifying pam.nix, which I'm reluctant to do as it will collide with future updates)?

You can add lines to the default value of security.pam.services.sudo.text using mkOverride or the shortcut mkDefault to give your value the same priority as the default. You can control the order with mkOrder or the shortcuts mkBefore and mkAfter. So to append, you could do:
security.pam.services.sudo.text = pkgs.lib.mkDefault( pkgs.lib.mkAfter "# hi" );
When there are multiple values for an option, only the values with the lowest priority are kept. If there are still multiple values, they are sorted and merged. mkOverride and mkOrder create special values that the code in modules.nix recognizes when it is doing this. Ordinary values have the default priority (100) and sort order (1000). pam.nix uses mkDefault for the value it creates for the text option, which makes the priority 1000, thus ordinary values will replace it instead of being merged.
The NixOS manual section on Modularity explains a bit more.
I don't think you can do this generically for environment.etc because the target file doesn't have to match the attribute name, and pam.nix in particular does not name any of its entries in environment.etc. It is more like a list of instructions that are processed in sequence. See etc.nix and
make-etc.sh

For the files of /etc/pam.d/sudo and other files in the same directory, a simple solution is to use security.pam.services.sudo.text, but my current best attempt requires hardcoding the original contents of the file.
security.pam.services.sudo.text = ''
existing contents of /etc/pam.d/sudo …
extra lines …
'';
Hopefully other answers will come up with a more general-purpose way of altering configuration files (and keeping their original contents).

Related

Search all programs within a package for a MODIFY statement

I want to search all programs - within a package - that use the statement:
modify itab_xyz from wa_itab_xyz
Preferably, the string should be searched with wild cards like itab*
for a range of itab_(values) like itab_abc, itab_def, itab_ghi
etc..
How do i do this in SAP ABAP?
Below is a screenshot of all programs within a package one can search from.
One possibility would be to use program RS_ABAP_SOURCE_SCAN.
You can restrict the selection by package and you can also enter a specific string to search for in the code.
I use the transaction code_scanner (program is afx_code_scanner).
The biggest problem with this program and the RS_ABAP_SOURCE_SCAN provided above is that they won’t find everything. IMO the most important missing component to them is implicit enhancements. They can be very impactful to system functions, and if you are searching for an error message or hard coded value skipping them could mean not finding something critical.
At the time I looked (about 7 years ago), I was unable to find a delivered tool that would actually scan all the code in the system. I ended up enhancing the code_scanner to look for enhancements, WDA components, BSP code, and forms code.
I don’t know if the open source component above includes those. At first glance it doesn’t seem to, but I don’t have time to really dig into it.
You could use a tool from the Galileo-Open Source library. This program searches ABAP Source, OTR-Texts, Message and Textpools for static Text, wildcard patterns or regex patterns.
ABAP-Coding:
https://github.com/galileo-group/galileo-abap-lib/blob/master/%23gal%23devtools_find_text.prog.abap
Textpool:
https://github.com/galileo-group/galileo-abap-lib/blob/master/%23gal%23devtools_find_text.prog.xml
It refers to some additional classes from the library, so you either need to copy these as well or just use ABAPgit to get the whole library. You can also contact me, so I can send you a transport containing the library.
Additional information (October 1, 2020):
I created a version of the report that you can copy/paste to the ABAP editor. It is too long to include it in the response, but you can find it here.
Do not forget to copy the text elements / selection texts.
Required Text Elements:
-----------------------
B00 Scope
B01 Search pattern
H01 Type
H02 Name
H03 Key
H04 Match
Required Selection Texts:
-------------------------
P_CASE Case-sensitive
P_DEVC Package
P_LANGU Language
P_MESS Messages
P_OTR OTR Texts
P_PATT Pattern
P_REGEX Regular expression
P_SOURCE ABAP sources
P_TPOOL Textpools
P_WILDC Wildcard pattern

Why do I get a syntax error on a record type definition in Delphi scripting? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I tried to make a custom record type in order to store information of a product and call it in functions and procedures when needed. The code is written in a script compiler of a Delphi based ERP program. The problem I'm facing is that I get a syntax error on the record type definition when I execute the script.
I searched the internet for an hour or so, but wasn't able to find a solution. My script is as next:
Unit Paneelwand;
interface
Uses System, Classes, DB, SysUtils, Graphics, Types;
type
TPanel = record
Ref, PType : string;
Width, Heigth, Thickness, PriceSheets, PriceBitum, PriceHardboard, PricePermmFrameWidth, PricePermmFrameHeigth : float;
end;
implementation
//rest of the code
The syntax Error is on line 6 "TPanel = record". I can't find what I did wrong. Please, help?
By the way: the script is saved as a .psc file and referenced to in another script with its filename as a reference in the uses section. This works fine with other scripts I wrote. I also never had to add a unit line as the scripts are called by the file names.
I updated the script, by deleting the part that is not part of the problem and added the changes that were suggested below by the great people that try to help me. However, the error remains on the same line --> 'TPanel = record;'.
"Type" is reserved word. try other word

CHM/HHP: maximum length of variable names in [ALIAS] section

What is the maximum length of variable names in the [ALIAS] section of HHP files?
I_AM_WONDERING_ABOUT_THE_MAXIMUM_LENGTH_OF_THIS_STRING_RIGHT_HERE=this-is-some-really-helpful-html-file.html
I have found a CHM/HHP specification right here:
https://www-user.tu-chemnitz.de/~heha/viewchm.php/hs/chmspec.chm/hhp.html
That page only talks about the length of the overall line, though (and not about the length of the variable name). Very specific question, I know. Still, someone may be able to point me somewhere.
As far as I know never asked before and I never heard about limitations. But I think this is because nobody used long variable names in this place so far.
The purpose of the two files e.g. alias.h and map.h is to ease the coordination between developer and help author. The mapping file links an ID to the map number - typically this can be easily created by the developer and passed to the help author. Then the help author creates an alias file linking the IDs to the topic names. That was the idea behind years (decades) ago by Ralph Walden (ex Microsoft).
Please note HTMLHelp is about 20 years old and these context ID strings inside a alias.h file were derived from WinHelp as a predecessor of HTMLHelp.
You'll find some further Information at Creating Context-Sensitive Help for Applications.
In general I'd recommend to use ID's with a fixed format because of the better legibility like shown below:
;-------------------------------------------------------------
; alias.h file example for HTMLHelp (CHM)
; www.help-info.de
;
; All IDH's > 10000 for better format
; last edited: 2006-07-09
;---------------------------------------------------
IDH_90001=index.htm
IDH_10000=Context-sensitive_example\contextID-10000.htm
IDH_10010=Context-sensitive_example\contextID-10010.htm
IDH_20000=Context-sensitive_example\contextID-20000.htm
IDH_20010=Context-sensitive_example\contextID-20010.htm
I'd recommend to use less than 1024 bytes per line.

CustomActionData with semi-colon separated, causes string overflow - What are the common workaround to this solution?

There were few attempts of questions answerered in regards to ICE03 (String overflow) for CustomActionData, but I cannot seem to determine/conclude the correct (or accepted) practice of how to go around this issue.
My current resolution was to reduce the length of the key-value-pair by keeping both the key and property names short, i.e. from:
<CustomAction Id="MyCustomActionData"
Property="MyCustomActionCA"
Value="myKeyName1=[SOME_PROPERTY_NAME];myKeyName2=[SOME_DESCRIPTIVE_PROPNAME]"/>
to:
<CustomAction Id="MyCustomActionData"
Property="MyCustomActionCA"
Value="k1=[K1];k2=[K2]"/>
But I feel that I'm just sweeping the problem under the rug and sooner or later, I'll encounter again (also, this is based on assumptions of my additional question below).
The more obvious solution is the re-evaluate and re-design it so that least amount of data needs to be passed down to the C# CustomAction (the classic "why would you want to declare a function method to pass 20 parameters?" question by all code-reviewers). Obviously, for most languages today, we can easily redesign the API and pass an object (as a class, struct, etc - depends on languages) that self-contains what it needs, but how does one go about it for inter-process calls (I've seen JSON RPC messages with reasonably large data and I'd usually wonder if it was because somebody tried to fix some legacy code by adding more and more until it got bloated rather than sitting down and re-design, which is not possible on some "11th hour" deadline that just has to get fixed in shortest time allowed).
Perhaps the solution is to create an XML file and use expat ('util:XmlFile') to search and replace the key-value-pair before calling CustomAction, and pass the filename of the altered XML as CustomActionData for CustomAction to use, which then in C# CustomAction code, it just deserializes it and treats it as objects. But that too feels a little klunky (it may also confuse the next developer who takes over my task in the future), not to mention if it was passwords we'd want to not have it in an XML file and keep it as Property with Hidden="yes"...
So my question is, what are the clean/elegant solutions or pattern (or practices) to resolve this issue of passing CustomActionData that may exceed table column size?
If I may also ask an additional question which is somewhat related, I am assuming that the linker (light) warning LGHT1076 is based on the length of the value (i.e. "keyA=[A];keyB=[B]") being too long, and so if I chose very short property variable and key-names, it would most likely not trigger this warning. But from what I understand, the table column size is 255 characters (please correct me if I'm wrong) thus during the run-time, if property value is longer than column size, it can cause some issue (or truncated)?
The solution I use is to create multiple properties and then concatenate the properties at the end into a single property, this way:
<CustomAction Id="SetSqlProperties"
Property="SqlProperties"
Value="SQL_LOGIN_ID=[SQL_LOGIN_ID];SQL_PASSWORD=[SQL_PASSWORD];
SQL_AUTH_TYPE=[SQL_AUTH_TYPE];SQL_SERVERS=[SQL_SERVERS]" />
<CustomAction Id="SetServerProperties"
Property="ServerProperties"
Value="Domain=[DOMAIN];ComputerName=[COMPUTER_NAME];
FullServerName=[FULLCOMPUTERNAME];Version=[ProductVersion];
ServerType=[SERVER_TYPE];SrvMode=[SrvMode]" />
<CustomAction Id="SetPropertiesConfigReplace"
Property="ConfigReplace"
Value="InstallFolder=[INSTALLFOLDER];[ServerProperties];[SqlProperties]" />
In this example I would use the property [ConfigReplace] containing all values from SQL Server and local server.
About the ICE03, in the documentation you can find this:
The string's length is greater than the column width specified by the column definition. Note that the installer does not internally limit the column width to the specified value. See Column Definition Format.
MSDN

Controlling Doxygen's LaTeX output for making PDF documentation

I'm using Doxygen to generate documentation for my code. I need to make a PDF version of this and using Doxygen's LaTeX output appears to be the way to do it.
However I've run into a number of annoying problems, and not knowing anything about LaTeX previously haven't really got much of an idea on how to approach them, and the countless references for LaTeX related things are not much help...
I worked out how to create a custom style thing in a sty file and how to get Doxygen to use it. After a lot of searching I found out how to set the page margins etc. through this, and I'm guessing the perhaps this is the file I want for doing the other things I want, but I cant seem to find any commands for doign what I want :(
The table of contents at the start of the document contains a lot of items Id rather it didn't as it makes the contents very long. Is there some way to limit this contents to just say the first two levels, rather than having entries for every single individual function, variable, etc.? Id quite like to keep all the bookmarks however. I did try the "COMPACT_LATEX" option but as well as removing items on the contents pages, it removed the bookmarks and the member lists at the start of each section, which I do really want to keep.
Is there a way to change the order of things, like putting the full class description at the start of the section, rather than after all the members and attributes?
Wow, that's kind of evil of Doxygen.
Okay, to get around the tocdepth counter problem, add the following line to your .sty file:
\AtBeginDocument{\setcounter{tocdepth}{2}}% or whatever level you want
You can set the PDF bookmarks depth to a separate value:
% requires you \usepackage{hyperref} first
\hypersetup{
bookmarksdepth = section, % of whatever level you want
}
Also note that if you have a list of figures/tables, the tocdepth must be at least 2 for them to show up.
I don't see any way of rearranging those items within the LaTeX files---Doxygen just barfs them out there, so we can't do much. You'll have to poke around the Doxygen documentation to see if there's any way to specify the order I guess. (Here's hoping!)
You're so close.
Googling on "latex contents level" brought me to LaTeX - customizing the depth of the table of contents for different parts of the thesis which suggests
\setcounter{tocdepth}{n}
where n starts at zero for only the highest level division. This is presumable defined in all the default styles, but is worth a try in doxygen.
You could write a Perl/Awk script to simply delete the unwanted lines from the table of contents. For the file burble.tex, Latex will generate the file burble.toc, which will contain lines such as:
\contentsline {subsection}{Class F rewrites}{38}
\contentsline {subsection}{Class M rewrites}{39}
\contentsline {section}{\numberline {7}Definition and properties of the translation}{44}
\contentsline {paragraph}{Well-formedness}{54}
Simple regexes will identify which levels each line belongs to, and you can filter the file based on that. Once you have the table of contents the way you want it, insert \nofiles in the appropriate place (the style sheet?), which means that Latex will read the auxiliary files but not overwrite them.