Reputation: 465
So, here is the function that should create and write string into a /proc/minifwdb:
int write_to_file(char* rule)
{
FILE* fin;
fin = fopen("/proc/minifwdb", "a");
if (!fin)
{
printf("Could not open the file /proc/minifwdb, exiting...\n");
return 1;
}
if (fprintf(fin, "%s\n", rule) < 0)
return 1;
fclose(fin);
return 0;
}
When fopen() is called, it returns NULL. And there is no such file as /proc/minifwdb currently. Do I need to create it using LKM, and then use it to write the info? I am also trying to create it from the user that has no root access. Any suggestions?
Upvotes: 0
Views: 1646
Reputation: 180010
Files in /proc
are used as an interface between user space and the kernel.
It is possible to use such a file to pass a string from user space into the kernel, but the kernel code that wants to receive it is responsible for creating the file.
Upvotes: 2